-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiceTable.java
72 lines (33 loc) · 1.01 KB
/
DiceTable.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
65
66
67
68
69
70
71
import java.util.Scanner;
import java.util.Random;
public class DiceTable{
static Random randop=new Random();
static int[] dicetallyarray=new int[13];
static Scanner input=new Scanner(System.in);
static int numberofrolls;
public static void main(String[]args) {
numberofrolls=howmanyrolls();
rolldice(numberofrolls);
displaytable();
}
private static int howmanyrolls() {
System.out.println("How many dice rolls do u want");
return input.nextInt();
}
private static void rolldice(int numberofrolls) {
int dice1;
int dice2;
int thesum;
for (int i=0; i<=numberofrolls; i++) {
thesum=(randop.nextInt(5)+1)+(randop.nextInt(5)+1);
++dicetallyarray[thesum];
}
}
private static void displaytable() {
System.out.println("Sum Occurences");
for (int c=1; c<dicetallyarray.length; c++) {
System.out.printf("%d %d",c,dicetallyarray[c]);
System.out.println(" ");
}
}
}