Assignment #55
Code
/// Name: Kabir Virk
/// Period: 6
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date Finished: 12/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: \"Follow your dreams.\"");
else if (fortune == 2)
System.out.println("Fortune cookie says: \"A gift is coming your way.\"");
else if (fortune == 3)
System.out.println("Fortune cookie says: \"Success is around the corner.\"");
else if (fortune == 4)
System.out.println("Fortune cookie says: \"A family member nearby is waitinf for yo.\"");
else if (fortune == 5)
System.out.println("Fortune cookie says: \"You will get a puppy in your life.\"");
else if (fortune == 6)
System.out.println("Fortune cookie says: \"You will achieve prosperity and peace.\"");
else
System.out.println("Fortune Error");
System.out.println(" " + fort1 + " - " + fort2 + " - " + fort3 + " - " + fort4 + " - " + fort5 + " - " + fort6);
}
}
Picture of the output