Assignemnt #57: Dice
Code
///Name: Cassie
///Period: 6
///Program Name: Dice
///File Name: dice.java
///Date Finished: 12/3/15
import java.util.Random;
public class Dice
{
public static void main ( String[] args )
{
Random r = new Random();
int die1 = 1 + r.nextInt(6), die2 = 1 + r.nextInt(6);
if ( die1 == 1 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 1 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die1 == 2 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 2 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die1 == 3 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 3 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die1 == 4 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 4 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die1 == 5 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 5 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die1 == 6 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 6 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
if ( die2 == 1 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 1 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die2 == 2 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 2 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die2 == 3 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 3 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die2 == 4 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 4 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die2 == 5 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 5 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
else if ( die2 == 6 )
{
System.out.println( " _____" );
System.out.println( "| |" );
System.out.println( "| 6 |" );
System.out.println( "| |" ):
System.out.println( " ----- " );
}
System.out.println( "You rolled a total of " + ( die1 + die2) + "." );
}
}
Picture of the output