Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lastRollSum = 0;
- int currentRoll = 0;
- int count = 0;
- while (lastRollSum != 2 && currentRoll != 2) {
- int die1 = (int) (Math.random() * 6) + 1, die2 = (int) (Math.random() * 6) + 1;
- System.out.println ("You rolled " + die1 + " & " + die2 + ", last roll sum:" + lastRollSum);
- lastRollSum = currentRoll;
- currentRoll = die1 + die2;
- count++;
- }
- System.out.println("It took " + count + " tries.");
Add Comment
Please, Sign In to add comment