Assignemnt #56 and Fortune Cookie
Code
/// Name: David Shkolnikov
/// Period: 6
/// Program Name: Fortune Cookie
/// File Name: FortuneCookie.java
/// Date Finished: 11/30/2015
import java.util.Random;
public class FortuneCookie
{
public static void main( String[] args )
{
Random r = new Random();
int fortune = 1 + r.nextInt(6);
String cookie = "";
if ( fortune == 1 )
cookie = "prepare to be wealthy.";
else if ( fortune == 2 )
cookie = "beware of your significant other's actions.";
else if ( fortune == 3 )
cookie = "Today is a good day.";
else if ( fortune == 4 )
cookie = "The rest of this year is bout to be bumpin.";
else if ( fortune == 5 )
cookie = "beware of spiders today.";
else if ( fortune == 6 )
cookie = "Feliz Cumpleanos!";
System.out.println("Fortune cookie says: \"" + cookie + "\"");
System.out.print("\t" + (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.println( 1 + r.nextInt(54) );
}
}
Picture of the output