Assignment 71: Shorter Double Dice
Code
/// Name: Ryan McAteer
/// Period: 5
/// Program Name: Shorter Dice Doubles
/// File Name: Assignment71.java
/// Date Finished: 12/15/15
import java.util.Random;
public class Assignment71
{
public static void main ( String[] args )
{
Random r = new Random();
System.out.println("HERE COMES THE DICE!");
int diceOne = 1 + r.nextInt(6);
int diceTwo = 1 + r.nextInt(6);
int total = diceOne + diceTwo;
System.out.println();
System.out.println("Roll #1: " + diceOne + ".");
System.out.println("Roll #2: " + diceTwo + ".");
System.out.println("Total: " + total + ".");
do
{
diceOne = 1 + r.nextInt(6);
diceTwo = 1 + r.nextInt(6);
System.out.println();
System.out.println("Roll #1: " + diceOne + ".");
System.out.println("Roll #2: " + diceTwo + ".");
System.out.println("Total: " + total + ".");
} while ( diceOne != diceTwo );
System.out.println("As you can see, the total is " + total + ".");
}
}
Picture of the output