Assignemnt #56, Fortune Cookie
Code
import java.util.Scanner;
import java.util.Random;
public class prog56
{
public static void main( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int x;
x = 1 + r.nextInt(6);
if ( x == 1 )
System.out.println( "Fortune cookie says: \"Good fortune is coming your way.\"" );
if ( x == 2 )
System.out.println( "Fortune cookie says: \"Stick with the job you have it will bring good fortune.\"" );
if ( x == 3 )
System.out.println( "Fortune cookie says: \"You will be wealthy soon.\"" );
if ( x == 4 )
System.out.println( "Fortune cookie says: \"Stay away form snakes.\"" );
if ( x == 5 )
System.out.println( "Fortune cookie says: \"Watermelons bring bad luck.\"" );
if ( x == 6 )
System.out.println( "Fortune cookie says: \"You must construct additional pylons.\"" );
System.out.print( 1 + r.nextInt(99) + " - " );
System.out.print( 1 + r.nextInt(99) + " - " );
System.out.print( 1 + r.nextInt(99) + " - " );
System.out.print( 1 + r.nextInt(99) + " - " );
System.out.print( 1 + r.nextInt(99) + " - " );
System.out.println( 1 + r.nextInt(99) + " - " );
}
}
Picture of the output