Assignment #56 and Fortune Cookie
Code
/// Name: Mahima Choudhary
/// Period: 6
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date Finished: 11/2/2015
import java.util.Random;
public class FortuneCookie
{
public static void main(String[] args)
{
Random r = new Random();
int fortune = 1 + r.nextInt(6);
int fort1 = 1 + r.nextInt(54);
int fort2 = 1 + r.nextInt(54);
int fort3 = 1 + r.nextInt(54);
int fort4 = 1 + r.nextInt(54);
int fort5 = 1 + r.nextInt(54);
int fort6 = 1 + r.nextInt(54);
if (fortune == 1)
System.out.println("Fortune cookie says: \"Aspire for greatness.\"");
else if (fortune == 2)
System.out.println("Fortune cookie says: \"You will become the president some day.\"");
else if (fortune == 3)
System.out.println("Fortune cookie says: \"You will win the lottery.\"");
else if (fortune == 4)
System.out.println("Fortune cookie says: \"Being yourslef will p[ave the way for success.\"");
else if (fortune == 5)
System.out.println("Fortune cookie says: \"You will get married to the lov eof your life.\"");
else if (fortune == 6)
System.out.println("Fortune cookie says: \"You will have a child genius.\"");
else
System.out.println("Fortune Error");
System.out.println(" " + fort1 + " - " + fort2 + " - " + fort3 + " - " + fort4 + " - " + fort5 + " - " + fort6);
}
}
Picture of the output