Assignemnt #56 and FortuneCookie
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: Forty-Sixth Program
/// file name: FortuneCookie.java
/// date finished: 11/19/15
import java.util.Random;
import java.util.Scanner;
public class FortuneCookie
{
public static void main ( String[] args )
{
Random r = new Random();
int x = 1 + r.nextInt(54);
String response = "";
if ( x == 1 )
response = "It is your lucky day";
else if ( x == 2 )
response = "It is your unlucky day";
else if ( x == 3 )
response = "You will win the a great prize";
else if ( x == 4 )
response = "Stay in school you'll need it";
else if ( x == 5 )
response = "Your lover awaits";
else if ( x == 6 )
response = "Be careful what you wish for";
System.out.println( "Fortune cookie says: " + response);
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.print( 1 + r.nextInt(54) + " " );
System.out.println();
}
}
Picture of the output