Assignemnt #56
Code
/// Name: Daniel Nguyen
/// Period: 6
/// Program Name: FortuneCookie Program
/// File Name: FortuneCookie.java
/// Date Finished: 9/9/2015
import java.util.Random;
import java.util.Scanner;
public class FortuneCookie
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int guess;
int rng = 1 + r.nextInt(6);
String message = "";
if (rng == 1) {
message = "Today is your lucky day.";
}
else if (rng == 2) {
message = "Change can hurt, but it can also lead to something better.";
}
else if (rng == 3) {
message = "Stick with your wife.";
}
else if (rng == 4) {
message = "These lucky numbers will win you the lottery.";
}
else if (rng == 5) {
message = "Eat more tacos.";
}
else {
message = "Cows will be attracted to you.";
}
System.out.println("Fortune Cookie says: " + message);
System.out.println("");
System.out.println((1 + r.nextInt(54)) + " - " + (1 + r.nextInt(54)) + " - " + (1 + r.nextInt(54)) + " - " + (1 + r.nextInt(54)) + " - " + (1 + r.nextInt(54)) + " - " + (1 + r.nextInt(54)));
}
}
Picture of the output