PROGRAMMING AND CODE


Assignemnt #71

Code

/// Name: Justin Li
/// Period 7
/// Program Name: DiceDoubles2
/// File Name: DiceDoubles2.java
/// Date Finished: 1/23/15

import java.util.Scanner;
import java.util.Random;

class DiceDoubles2 {
  
    public static void main(String[]args) {
      
        Random r = new Random();
        
        Scanner keyboard = new Scanner(System.in);
        
        int one, two, total;
        one = 1 + r.nextInt(6);
        two = 1 + r.nextInt(6);
        total = one + two;
        
        while(one != two)
        {
            System.out.println("Roll #1: " + one);
            System.out.println("Roll #2: " + two);
            System.out.println("\nThe total is " + total);
            one = 1 + r.nextInt(6);
            two = 1 + r.nextInt(6);
            total = one + two;
        }
        System.out.println("Roll #1: " + one);
        System.out.println("Roll #2: " + two);
        System.out.println("\nThe total is " + total);
          
    }
}
    

Picture of the output

Assignment 1