Assignment #71 and Shorter Double Dice
Code
/// Name: Tim Chuang
/// Period: 7
/// Program Name: Shorter Double Dice
/// File Name: ShorterDoubleDice.java
/// Date Finished: 1/10/2016
import java.util.Random;
public class ShorterDoubleDice
{
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