Assignment #56: Fortune Cookie
Code
/// Name: Kiran O'Farrell
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date completed: 12/2/15
import java.util.Random;
public class FortuneCookie {
public static void main (String[] args) {
Random r = new Random();
int fortune = 1 + r.nextInt(6);
int lucky1 = 1 + r.nextInt(54);
int lucky2 = 1 + r.nextInt(54);
int lucky3 = 1 + r.nextInt(54);
int lucky4 = 1 + r.nextInt(54);
int lucky5 = 1 + r.nextInt(54);
int lucky6 = 1 + r.nextInt(54);
String response;
System.out.println("Your fortune cookie says:");
if (fortune == 1) {
System.out.println("With great power comes great responsibility.");
}
else if (fortune == 2) {
System.out.println("Nitwit! Blubber! Oddment! Tweak!");
}
else if (fortune == 3) {
System.out.println("We are all connected in the great Circle of Life.");
}
else if (fortune == 4) {
System.out.println("He who breaks a thing to find out what it is has left the path of wisdom.");
}
else if (fortune == 5) {
System.out.println("Wax on, wax off.");
}
else if (fortune == 6) {
System.out.println("Do or do not. There is no try.");
}
System.out.println("Your lucky numbers are " + lucky1 + " - " + lucky2 + " - " + lucky3 + " - " + lucky4 + " - " + lucky5 + " - " + lucky6);
}
}
Picture of the output