Assignemnt #56 and Fortune Cookie
Code
/// Name: Tristan Chung
/// Period: 5
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date Finished: 11/18/2015
import java.util.Random;
public class FortuneCookie
{
public static void main ( String[] args )
{
Random r = new Random();
int choice;
String fortune = "";
choice = 1 + r.nextInt(6);
String response = "";
int num1 = 1 + r.nextInt(54);
int num2 = 1 + r.nextInt(54);
int num3 = 1 + r.nextInt(54);
int num4 = 1 + r.nextInt(54);
int num5 = 1 + r.nextInt(54);
int num6 = 1 + r.nextInt(54);
if ( choice == 1 )
fortune = "Your hard work will be rewarded.";
else if ( choice == 2 )
fortune = "You may experience a tragedy.";
else if ( choice == 3 )
fortune = "A person you know will save your life.";
else if ( choice == 4 )
fortune = "You will be rich soon.";
else if ( choice == 5 )
fortune = "Your character will be recognized soon.";
else if ( choice == 6 )
fortune = "You will find happiness.";
System.out.println( "Fortune Cookie says: " + fortune );
System.out.println( " " + num1 + " - " + num2 + " - " + num3 + " - " + num4 + " - " + num5 + " - " + num6);
}
}
Picture of the output