Assignment #59 and Three Card Monte
Code
/// Name: Lauren Baird
/// Period: 7
/// Program Name: Three Card Monte
/// File Name: ThreeCard.java
/// Date Finished: 11/3/2015
import java.util.Random;
import java.util.Scanner;
public class ThreeCard
{
public static void main( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int guess;
int ball = 1 + r.nextInt(3);
System.out.println( "Your friend slides three cups onto the table infront of you." );
System.out.println( "\"There is a ball under one of these cups. If you can guess which one it's under, I'll pay for our food. If you don't guess correctly you're paying.\" ");
System.out.println();
System.out.println( "Which cup the ball under?" );
System.out.println();
System.out.println( " 1. _ 2. _ 3. _ " );
System.out.println( " | | | | | | " );
System.out.println();
guess = keyboard.nextInt();
System.out.println();
if ( guess == ball )
{
System.out.println( "You got it!");
}
else
{
System.out.println( "Nope! " );
}
if ( ball == 1 )
{
System.out.println( " _ " );
System.out.println( " | | _ _ " );
System.out.println( " o | | | | " );
}
if ( ball == 2 )
{
System.out.println( " _ " );
System.out.println( " _ | | _ " );
System.out.println( " | | o | | " );
}
if ( ball == 3 )
{
System.out.println( " _ " );
System.out.println( " _ _ | | " );
System.out.println( " | | | | o " );
}
}
}