Assignment #56 and Fortune Cookie
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Fortune Cookie
///File Name: FotruneCookie.java
///Date Finished: 10/15/15
import java.util.Random;
public class FortuneCookie
{
public static void main ( String[] args )
{
Random r = new Random();
int fortune, a, b, c, d, e, f;
String response = "error";
fortune = 1 + r.nextInt(6);
a = 1 + r.nextInt(54);
b = 1 + r.nextInt(54);
c = 1 + r.nextInt(54);
d = 1 + r.nextInt(54);
e = 1 + r.nextInt(54);
f = 1 + r.nextInt(54);
if ( fortune == 1 )
response = "You will live long and happy life and eat many more fortune cookies.";
else if ( fortune == 2 )
response ="You should buy another fortune cookie.";
else if ( fortune == 3 )
response = "Friendship is good.";
else if ( fortune == 4 )
response = "Do your homework.";
else if ( fortune == 5 )
response = "You will have bad digestion because you ate this gross cookie.";
else if ( fortune == 6 )
response = "Eating cookies is good for you.";
System.out.println( "Fortune cookie says \"" + response + "\"" );
System.out.println( a + " - " + b + " - " + c + " - " + d + " - " + e + " - " + f );
}
}
Picture of the output