-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdice.java
64 lines (63 loc) · 1.68 KB
/
dice.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//exo7.17
import java.security.SecureRandom;
public class dice{
public static void main (String[] args){
SecureRandom random = new SecureRandom();
int p,i;
int[] b = new int[13] ;
for(i=0;i<b.length;i++)
b[i]=0;
long count= 36000000;
while(count!=0){
p = (1+ random.nextInt(6)) + (1+random.nextInt(6));//(int)(Math.random() * 10);
switch(p){
case 0:
b[0]++;
break;
case 1:
b[1]++;
break;
case 2:
b[2]++;
break;
case 3:
b[3]++;
break;
case 4:
b[4]++;
break;
case 5:
b[5]++;
break;
case 6:
b[6]++;
break;
case 7:
b[7]++;
break;
case 8:
b[8]++;
break;
case 9:
b[9]++;
break;
case 10:
b[10]++;
break;
case 11:
b[11]++;
break;
case 12:
b[12]++;
break;
default:
System.out.println("error this is not foun");
System.exit(1);
}
count--;
}
for(i=2;i<b.length;i++){
System.out.print("a "+i+" and the frequency are "+b[i]+"\n");
}
}
}