Guest User

Untitled

a guest
Dec 14th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. int lastRollSum = 0;
  2. int currentRoll = 0;
  3. int count = 0;
  4.  
  5. while (lastRollSum != 2 && currentRoll != 2) {
  6. int die1 = (int) (Math.random() * 6) + 1, die2 = (int) (Math.random() * 6) + 1;
  7. System.out.println ("You rolled " + die1 + " & " + die2 + ", last roll sum:" + lastRollSum);
  8. lastRollSum = currentRoll;
  9. currentRoll = die1 + die2;
  10. count++;
  11. }
  12.  
  13. System.out.println("It took " + count + " tries.");
Add Comment
Please, Sign In to add comment