Assignment #56 Fortune Cookie
Code
/// Name: Matthew Lorence
/// Period: 5
/// Program Name: FortuneCookie
/// File Name: FortuneCookie.java
import java.util.Random;
public class FortuneCookie
{
public static void main (String [] args)
{
Random r = new Random();
int word = 1 + r.nextInt(6);
System.out.print("Fortune cookie says: ");
if ( word == 1)
{
System.out.println("\"A samuri cut yo head off.\"");
}
if ( word == 2)
{
System.out.println("\"Life will give you luck.\"");
}
if ( word == 3)
{
System.out.println("\"Your hard work will pay off.\"");
}
if ( word == 4)
{
System.out.println("\"You will grow mentally.\"");
}
if ( word == 5)
{
System.out.println("\"Life is good.\"");
}
if ( word == 6)
{
System.out.println("\"You will prosper.\"");
}
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) + " - ");
}
}
Picture of the output