Assignment #56 Fortune Cookie
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date Finished: 11/17/2015
import java.util.Random;
public class FortuneCookie
{
public static void main( String[] args )
{
Random r = new Random();
int one, two, three, four, five, six, fortune;
one = 1 + r.nextInt(54);
two = 1 + r.nextInt(54);
three = 1 + r.nextInt(54);
four = 1 + r.nextInt(54);
five = 1 + r.nextInt(54);
six = 1 + r.nextInt(54);
fortune = r.nextInt(6);
System.out.println();
if ( fortune == 0 )
{
System.out.println( "Fortune cookie says: \"Stick with your wife.\"" );
System.out.println( " " + one + " - " + two + " - " + three + " - " + four + " - " + five + " - " + six );
}
if ( fortune == 1 )
{
System.out.println( "Fortune cookie says: \"Reflect upon the good in life.\"" );
System.out.println( " " + one + " - " + two + " - " + three + " - " + four + " - " + five + " - " + six );
}
if ( fortune == 2 )
{
System.out.println( "Fortune cookie says: \"You will endure hardships that will prove to be successful.\"" );
System.out.println( " " + one + " - " + two + " - " + three + " - " + four + " - " + five + " - " + six );
}
if ( fortune == 3 )
{
System.out.println( "Fortune cookie says: \"Sometimes its better to quit when your ahead.\"" );
System.out.println( " " + one + " - " + two + " - " + three + " - " + four + " - " + five + " - " + six );
}
if ( fortune == 4 )
{
System.out.println( "Fortune cookie says: \"Do what makes you happy.\"" );
System.out.println( " " + one + " - " + two + " - " + three + " - " + four + " - " + five + " - " + six );
}
if ( fortune == 5 )
{
System.out.println( "Fortune cookie says: \"If everything came easy, no one would push the limits.\"" );
System.out.println( " " + one + " - " + two + " - " + three + " - " + four + " - " + five + " - " + six );
}
System.out.println();
}
}
Picture of the output