Assignment #56 and Fortune Cookie
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date Finished: 10/7/2015
import java.util.Random;
public class FortuneCookie
{
public static void main ( String[] args )
{
Random r = new Random();
int choice = 1 + r.nextInt(6);
String response = "";
if ( choice == 1 )
response = "An adventure is in your near future";
else if ( choice == 2 )
response = "A great opportunity is headed your way";
else if ( choice == 3 )
response = "Now is the time to take a chance";
else if ( choice == 4 )
response = "A new phase of your life will begin soon";
else if ( choice == 5 )
response = "You will have very good luck tomorrow";
else if ( choice == 6 )
response = "Keep your friends close for the next few days";
else
response = "ERROR";
System.out.println( "Fortune cookie says: \"" + response + ".\"" );
System.out.print( "\t" );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( "- " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( "- " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( "- " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( "- " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( "- " );
System.out.println( 1 + r.nextInt(54) + " " );
}
}
Picture of the output