View Single Post
Old May 1st, 2007, 4:37 PM   #1
aggelos
Newbie
 
Join Date: May 2005
Posts: 16
Rep Power: 0 aggelos is on a distinguished road
some simple JavaScript help please

Hello, I was wondering if someone might be able to help me do something with a little program I'm testing. So this is what I've dont so far..

<html><head><title>JavaScript programming</title></head>
<body>
<script language="javascript">

document.write("<H1>Lottery number selection</H1><br> ");

alert("Hi! are you ready for your lottery numbers");

document.write("Then let us get going");

how_many=window.prompt("How many sets of number do you require","0");
temp_storage = new Array(6)
for (j=0; j<how_many; j++)
{
document.write("<br>Set ", j+1," lottery number are ");
for (i=0; i<=6; i++)
temp_storage[i]=0;//
for (i=1; i<=6; i++)
{
num = Math.random();
num=(num*48)+1;
num=Math.round(num);
switch(num)
{
case temp_storage[0]:
i--;
break;
case temp_storage[1]:
i--;
break;
case temp_storage[2]:
i--;
break;
case temp_storage[3]:
i--;
break;
case temp_storage[4]:
i--;
break;
case temp_storage[5]:
i--;
break;
default : temp_storage[i-1]=num;
}
}
for (i=0; i<6; i++)
{
num=temp_storage[i];
document.write(num, " ");
}
}
</script></body></html>

And so what I basically want to add is to see how good the random number generator is at producing random numbers. The user should input the range of integer numbers required and the number to sample it. Then i want it to display something like this:

(m) random numbers were selected between 1 and (n) – (where m and n are input)

Number No. of times selected ideal is (x) % selected ideal is (y) – (where x and y are input)

Eg.
100 random numbers were selected between 1 and 5

Number No. of times selected ideal is 20 %selected ideal is 20%
1 18 18%
2 22 22%
.
5 16 16%


Can someone help me to do this?
aggelos is offline   Reply With Quote