Assignemnt #62
Code
/// Name: Sam Menar
/// Period: 6
/// Program Name: Dice Doubles
/// File Name: DiceDoubles.java
/// Date Finished: 12/14/15
import java.util.Random;
public class DiceDoubles
{
public static void main( String[] args )
{
Random r = new Random();
System.out.println( "HERE COMES THE DICE!" );
System.out.println( " " );
int dice1, dice2, total;
dice1 = 1 + r.nextInt(6);
dice2 = 1 + r.nextInt(6);
total = dice1 + dice2;
System.out.println( "Roll #1: " + dice1 );
System.out.println( "Roll #2: " + dice2 );
System.out.println( "The total is " + total + "!" );
while (dice1 != dice2 )
{
dice1 = 1 + r.nextInt(6);
dice2 = 1 + r.nextInt(6);
total = dice1 + dice2;
System.out.println( "Roll #1: " + dice1 );
System.out.println( "Roll #2: " + dice2 );
System.out.println( "The total is " + total + "!" );
}
}
}
Picture of the output