Assignemnt #56 Fortune Cookie
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: FortuneCookie
/// File Name: FortuneCookie.java
/// Date Finished: 12/3/2015
import java.util.Random;
public class FortuneCookie
{
public static void main (String[] args)
{
Random r = new Random();
int lotto1 = 1 + r.nextInt(54);
int lotto2 = 1 + r.nextInt(54);
int lotto3 = 1 + r.nextInt(54);
int lotto4 = 1 + r.nextInt(54);
int lotto5 = 1 + r.nextInt(54);
int lotto6 = 1 + r.nextInt(54);
int cookieNumber = 1 + r.nextInt(6);
System.out.print( "Fortune cookie says: ");
if (cookieNumber == 1)
{
System.out.print( "\"Stick with your wife\"\n");
}
else if (cookieNumber == 2)
{
System.out.print( "\"Go for a long walk\"\n");
}
else if (cookieNumber == 3)
{
System.out.print( "\"Deep breaths!\"\n");
}
else if (cookieNumber == 4)
{
System.out.print( "\"Time for a new hobby\"\n");
}
else if (cookieNumber == 5)
{
System.out.print( "\"More coffee?\"\n");
}
else if (cookieNumber == 6)
{
System.out.print( "\"Grab a beer\"\n");
}
else
{
System.out.print( "\"AN ERROR HAS OCCURRED\n");
}
System.out.println( lotto1 + "-" + lotto2 + "-" + lotto3 + "-" + lotto4 + "-" + lotto5 + "-" + lotto6);
}
}
Picture of the output