-
Notifications
You must be signed in to change notification settings - Fork 0
/
RollDice.java
61 lines (48 loc) · 1.47 KB
/
RollDice.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
import java.util.Random;
public class RollDice
{
public static void main(String[] args)
{
var randomNumber = new Random();
int frequency_1 = 0;
int frequency_2 = 0;
int frequency_3 = 0;
int frequency_4 = 0;
int frequency_5 = 0;
int frequency_6 = 0;
int face = 0;
for (int i = 1; i <= 6_000_000; i++)
{
// random number in between (1 - 6)
face = (1 + randomNumber.nextInt(6));
switch (face)
{
case 1:
++frequency_1;
break;
case 2:
++frequency_2;
break;
case 3:
++frequency_3;
break;
case 4:
++frequency_4;
break;
case 5:
++frequency_5;
break;
case 6:
++frequency_6;
break;
}
}
System.out.println("Face\tFrequency");
System.out.println("1\t" + frequency_1);
System.out.println("2\t" + frequency_2);
System.out.println("3\t" + frequency_3);
System.out.println("4\t" + frequency_4);
System.out.println("5\t" + frequency_5);
System.out.println("6\t" + frequency_6);
}
}