Assignemnt #71 and ShorterDice
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: Sixty-First Program
/// file name: ShorterDice.java
/// date finished: 12/15/15
import java.util.Scanner;
import java.util.Random;
public class ShorterDice
{
public static void main( String[] args )
{
Random r = new Random();
int num1 = 1 + r.nextInt(6);
int num2 = 1 + r.nextInt(6);
System.out.println("Here comes the dice!");
System.out.println("");
System.out.println("Roll 1: " + num1);
System.out.println("Roll 2: " + num2);
System.out.println("");
int total = num1 + num2;
System.out.println("Your total is " + total);
do while (num1 != num2)
{
num1 = 1 + r.nextInt(6);
num2 = 1 + r.nextInt(6);
System.out.println("Roll #1: " + num1);
System.out.println("Roll #2: " + num2);
total = num1 + num2;
System.out.println("The total is " + total + "!");
System.out.println();
} while (num1 != num2);
}
}
Picture of the output