While Loops #62 (Doubles!)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name:Dice Doubles
/// File Name:DiceDoubles.java
/// Date Finished: 12/7/2015
import java.util.Random;
public class DiceDoubles
{
public static void main ( String[] args )
{
Random r = new Random();
int number2 = 1 + r.nextInt(6);
int number1 = 1 + r.nextInt(6);
System.out.println( "HERE COMES THE DICE! ");
System.out.println("");
System.out.println("Roll #1: " + number2 );
System.out.println("Roll #2: " + number1 );
System.out.println("The total is " + (number1 + number2) + "!");
while (number1 != number2) {
number2 = 1 + r.nextInt(6);
number1 = 1 + r.nextInt(6);
System.out.println( "HERE COMES THE DICE! ");
System.out.println("");
System.out.println("Roll #1: " + number2 );
System.out.println("Roll #2: " + number1 );
System.out.println("The total is " + (number1 + number2) + "!");
}
}
}
Picture(s) of the output