Assignment #56 and FortuneCookie
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: FortuneCookie
/// File Name: FortuneCookie.java
/// Date Finished:10/28/15
import java.util.Random;
public class FortuneCookie
{
public static void main (String[] args)
{
String fortune;
int randFortune;
Random r = new Random();
randFortune= 1 + r.nextInt(6);
if ( randFortune == 1)
{
fortune = "Stick with your wife.";
}
else if ( randFortune == 2 )
{
fortune = "Do not be greedy.";
}
else if ( randFortune == 3 )
{
fortune = "Do not give up what you are doing.";
}
else if ( randFortune == 4 )
{
fortune = "Be patient with your friends.";
}
else if ( randFortune == 5 )
{
fortune = "Something lucky will happy tomorrow.";
}
else
{
fortune = "Do what you want to do.";
}
System.out.println("Fortune cookie says: \"" + fortune + "\"");
System.out.println( "\t" + (1 +r.nextInt(54)) + " - " + (1 +r.nextInt(54)) + " - " + (1 +r.nextInt(54)) + " - " + (1 +r.nextInt(54)) + " - " + (1 +r.nextInt(54)) + " - " + (1 +r.nextInt(54)) );
}
}
Picture of the output