Program #71

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Shorter Double Dice
    /// File Name: Dice.java
    /// Date Finished: 12/18/2015 public class Dice

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

Picture of the output

Assignment 71