I'm working on a program for my classes lab and I seem to be using nextInt wrong and I was wondering if someone could help. I couldn't find a post that had an answer. The program is designed to experiment with loops in a rolling dice simulation. It it supposed to roll two dice, determine the result, and then make a tally if it's snake eyes or doubles or whatever it may be.
So I get the following error:
DiceSimulation.java:33: error: cannot find symbol
die1Value = nextInt();
^
symbol: method nextInt()
location: class DiceSimulation
DiceSimulation.java:34: error: cannot find symbol
die2Value = nextInt();
^
symbol: method nextInt()
location: class DiceSimulation
2 errors
This is the code I have, I'm not entirely sure how I've used nextInt wrong.
while (count < NUMBER)
{
die1Value = nextInt();
die2Value = nextInt();
if (die1Value == die2Value)
{
if (die1Value == 1)
{
snakeEyes += 1;
}
else if (die1Value == 2)
{
twos += 1;
}
else if (die1Value == 3)
{
threes += 1;
}
else if (die1Value == 4)
{
fours += 1;
}
else if (die1Value == 5)
{
fives += 1;
}
else if (die1Value == 6)
{
sixes += 1;
}
}
count += 1;
}
nextInt()fromScannerclass?nextInt()in your code, that's what the error is telling yourandom.nextInt()- you need to specify the appropriate [Random] object instance ..