Skip to content

Commit 3cb34f4

Browse files
committed
first commit
0 parents  commit 3cb34f4

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/Randomizer.iml
3+
/out/production/Randomizer/

Diff for: src/Randomizer.java

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import java.util.Arrays;
2+
import java.util.Random;
3+
import java.util.stream.Stream;
4+
5+
/**
6+
* Randomizer
7+
* each round, randomly pick a number from 0 to 9 (10 numbers to choose from)
8+
* do this 100 times and count each pick
9+
* perform 20 rounds
10+
* add up totals
11+
*/
12+
public class Randomizer {
13+
public static void main(String[] args) {
14+
var random = new Random();
15+
var count = new int[20][10];
16+
var total = new int[10];
17+
18+
System.out.println("00 01 02 03 04 05 06 07 08 09");
19+
System.out.println("-----------------------------");
20+
for (var x = 0; x < 20; x++) {
21+
for (var i = 0; i < 100; i++) {
22+
var num = random.nextInt(10);
23+
count[x][num]++;
24+
}
25+
for (var c : count[x]) {
26+
System.out.printf("%02d ", +c);
27+
}
28+
System.out.println();
29+
}
30+
for (var x = 0; x < 20; x++) {
31+
for (var i = 0; i < 10; i++) {
32+
total[i] += count[x][i];
33+
}
34+
}
35+
System.out.println(Arrays.toString(total));
36+
37+
}
38+
}

0 commit comments

Comments
 (0)