Hello fellow java programmers, I need help with an exercise found within this link (Exercise 3.1) Javanotes 6.0, Excercises for Chapter 3
Here's my code:
import java.util.Random; public class ExerciseThreeOne { public static void main(String[] args){ Random firstDiceRolls = new Random(); Random secondDiceRolls = new Random(); int runningTotal = 0; boolean snakeEyes = false; do { int firstDice = firstDiceRolls.nextInt(6) + 1; int secondDice = secondDiceRolls.nextInt(6) + 1; if ( (firstDice == 1) && (secondDice == 1) ) { snakeEyes = true; } else snakeEyes = false; runningTotal += 1; } while (snakeEyes = false); System.out.println("It took " + runningTotal + " time(s) to receive snake eyes."); } }
For some reason, the program keeps saying that it took 1 time to generate snake eyes.