Program #62

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Dice Doubles
    /// File Name: Dice.java
    /// Date Finished: 12/8/2015 public class Dice

          import java.util.Random;
          public class Dice
          {
              public static void main( String[] args )
              {
                  Random r = new Random();
                  int r1, r2, total;
                  r1 = 1 + r.nextInt(6);
                  r2 = 1 + r.nextInt(6);
                  total = r1 + r2;
                  System.out.println( "HERE COMES THE DICE! " );
                  System.out.println();
                  System.out.println( "Roll #1: " + r1 );
                  System.out.println( "Roll #2: " + r2 );
                  System.out.println( "The total is " + total + "!" );
                  
                  while ( r1 != r2 )
                  {
                      r1 = 1 + r.nextInt(6);
                      r2 = 1 + r.nextInt(6);
                      System.out.println();
                      System.out.println( "Roll #1: " + r1 );
                      System.out.println( "Roll #2: " + r2 );
                      System.out.println( "The total is " + total + "!" );
                  }
                  System.out.println( "The total is " + total + "!" );
              }
          }
          
             
    

Picture of the output

Assignment 62