Advertisement
Guest User

Untitled

a guest
Sep 9th, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.util.Random;
  2. public class DiceDoubles
  3. {
  4.   public static void main(String[] Args)
  5.   {
  6.     Random r = new Random();
  7.     int dice1 = -1, dice2 = -2, tries = 0;
  8.  
  9.     System.out.println("Here Comes The Dice!");
  10.  
  11.     while (dice1 != dice2)
  12.     {
  13.       dice1 = 1 + r.nextInt(6); dice2 = 1 + r.nextInt(6);
  14.       tries ++;
  15.       System.out.println("Roll #1: " + dice1 + "\nRoll #2: " + dice2 + "\nThe total is " + (dice1 + dice2) + "!\n");
  16.     }
  17.     System.out.println("\nYou got a double after " + tries + " tries!");
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement