Assignemnt #71: Using Do While Loops with a Doulbe Dice Simulation Model
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Dice Double with a Do While action.
/// File Name: DoWhileDice.java
/// Date Finished: 1/5/2016
import java.util.Random;
import java.util.Scanner;
public class DoWhileDice
{
public static void main ( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int x = 1 + r.nextInt(6);
int y = 1 + r.nextInt(6);
System.out.println( "Time to roll some dice today. " );
System.out.println();
do
{
y = 1 +r .nextInt(6);
x = 1 + r.nextInt(6);
System.out.println( " Roll #1: " + x );
System.out.println( " Roll #2: " + y );
System.out.println( " The total is " + (x+y) );
}
while ( x != y );
}
}
Picture of the output