Why isn't variable a and b getting any values? I have done so that a 100 sided dice with the numbers 1-100 is rolled 50.000 times and I wanna see how often it gives the number 1 and 100 but it isn't getting any value. The result still comes out as a= 0 and b = 0.
package Atest;
import javax.swing.*;
public class Tärning5{
public static void main(String[] arg){
int rolls;
double dice = (int) (Math.random()*100) + 1;
int n = 0;
int b=0, a=0;
for(rolls=50000; n<=rolls; dice = (int) (Math.random()*100) + 1) {
n++;
if(dice == 100)
a = a++;
else if (dice == 1)
b = b++;
}
JOptionPane.showMessageDialog(null, "Dice rolls " + rolls + " times"
+ "\n"
+ "\nDice landed on 100 " +a+" times"
+ "\nDice landed on 1 "+b+" times");
}
}