int numberOfRolls;
int diceFace;
int randomNumberDice = 0;
int count = 0;
int count2 = 0;
diceFace = readChoiceNumber();
System.out.println(spaces + " Please enter the number of times that you would like " + diceFace + " to appear in a row. " );
numberOfRolls = scan.nextInt();
int rolls = numberOfRolls;
scan.next();
while (count < rolls )
{
randomNumberDice = (int)((Math.random() * 6) + 1);
count2++;
if (randomNumberDice == diceFace)
{
count++;
}
else
{
count = 0;
}
}
return count2;
I think there is a problem with the If and Else statement but I can't figure it out.
Aucun commentaire:
Enregistrer un commentaire