The issue with my program is that it does not calculate how many times the specific value has occurred. I believe that I have everything in place, but I'm not sure to as why it wouldn't work. Any help and/or feedback is kindly appreciated. Thanks!
Ok, so basically this program is supposed to do the following:
Modify the die program so it rolls both dice 500 times. Count the number of times each value occurred.
Your output should look like this:
2's = n times
3's = n times
.
.
12's = n times
class HowManyDoubles{
public static void main (String[] args){
int die1, die2, times = 0, oneCount = 0, twoCount = 0, threeCount = 0, fourCount = 0, fiveCount = 0, sixCount = 0;
int sevenCount = 0, eightCount = 0, nineCount = 0;
int countAmount = 0, diceAmount = 0;
System.out.println ("Start rolling...");
while (countAmount != 500 && diceAmount != 500) {
die1 = (int)(Math.random()*6) + 1;
System.out.println ("First die: " + die1);
diceAmount++;
die2 = (int)(Math.random()*6) + 1;
System.out.println ("Second die: " + die2);
countAmount++;
}
for (int count = 0; count <= diceAmount || count <= countAmount; count++) {
switch (times) {
case 1:
oneCount += 1;
break;
case 2:
twoCount += 1;
break;
case 3:
threeCount += 1;
break;
case 4:
fourCount += 1;
break;
case 5:
fiveCount += 1;
break;
case 6:
sixCount += 1;
break;
case 7:
sevenCount += 1;
break;
case 8:
eightCount += 1;
break;
case 9:
nineCount += 1;
break;
}
}
System.out.println ("You rolled one's" + oneCount + " times.");
System.out.println ("You rolled two's" + twoCount + " times.");
System.out.println ("You rolled three's" + threeCount + " times.");
System.out.println ("You rolled four's" + fourCount + " times.");
System.out.println ("You rolled five's" + fiveCount + " times.");
System.out.println ("You rolled six's" + sixCount + " times.");
System.out.println ("You rolled seven's" + sevenCount + " times.");
System.out.println ("You rolled eight's" + eightCount + " times.");
System.out.println ("You rolled nine's" + nineCount + " times.");
}
}