So I had this while loop for a lab in my class I had to make. I then had to convert the loop to a do-while loop to see the difference in design and make sure I got the same results. Now I need to convert it into a for loop, but I don't know how to set up the for statement. Here is how it is currently:
do
{
die1Value = generator.nextInt(6) + 1;
die2Value = generator.nextInt(6) + 1;
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;
}while (count < NUMBER);
while, not yourdo while. The reason is that aforloop does its check at the beginning, not the end, just likewhile. So the original will be closer to what you want to finish with.