Dice Rolling


import java.util.Random;
    
    public class dice
    {
        
        public static void main( String[] args ) 
        {
            
            Random r = new Random();
            
            int d1, d2, total;
            
            System.out.println( "Here comes the dice" );
            System.out.println("We're gonna keep doin' this until the numbers are the same");
            
            d1 = 1 + r.nextInt(6);
            d2 = 2 + r.nextInt(6);
            total = d1 + d2;
            
            System.out.println( "The first roll is " + d1 );
            System.out.println( "The second role is " + d2 );
            System.out.println( "Your total is " + total );
            
            while ( d1 != d2 )
            {
            d1 = 1 + r.nextInt(6);
            d2 = 2 + r.nextInt(6);
            total = d1 + d2;    
                
            System.out.println("Nope, let's try again");
                
            System.out.println( "The first roll is " + d1 );
            System.out.println( "The second role is " + d2 );
            System.out.println( "Your total is " + total );
            }
            
            System.out.println("There we go");
        }
    }
    

Picture of the output

Assignment 62