Assignemnt #59: Three Card Monte
Code
///Name: Cassie
///Period: 6
///Program Name: Three Card Monte
///File Name: cards.java
///Date Finished: 12/3/15
import java.util.Random;
import java.util.Scanner;
class numguess
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int guess, cup = 1 + r.nextInt(3);
String response = "";
System.out.println( "You slide up to Fast Eddie's card table and plop down your cash." );
System.out.println( "He glances at you out of the corner of his eye and starts shuffling" );
System.out.println( "He lays down three cards." );
System.out.println( "Whcih one is the ace?" );
System.out.println( " " );
System.out.println( " *** *** *** " );
System.out.println( " *** *** *** " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
System.out.print( "> " );
guess = keyboard.nextInt();
if ( guess == 1 && guess == cup )
{
System.out.println( "You nailed it! Fast Eddie reluctantly hands over your winnings, scowling. " );
System.out.println( " " );
System.out.println( " A** *** *** " );
System.out.println( " **A *** *** " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
}
else if ( guess == 1 && guess != cup )
{
System.out.println( "Ha! Fast Eddie wins again! That card is a queen." );
System.out.println( " " );
System.out.println( " Q** *** *** " );
System.out.println( " **Q *** *** " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
}
else if ( guess == 2 && guess == cup )
{
System.out.println( "You nailed it! Fast Eddie reluctantly hands over your winnings, scowling. " );
System.out.println( " " );
System.out.println( " *** A** *** " );
System.out.println( " *** **A *** " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
}
else if ( guess == 2 && guess != cup )
{
System.out.println( "Ha! Fast Eddie wins again! That card is a queen." );
System.out.println( " " );
System.out.println( " *** Q** *** " );
System.out.println( " *** **Q *** " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
}
else if ( guess == 3 && guess == cup )
{
System.out.println( "You nailed it! Fast Eddie reluctantly hands over your winnings, scowling. " );
System.out.println( " " );
System.out.println( " *** *** A** " );
System.out.println( " *** *** **A " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
}
else if ( guess == 3 && guess != cup )
{
System.out.println( "Ha! Fast Eddie wins again! That card is a queen." );
System.out.println( " " );
System.out.println( " *** *** Q** " );
System.out.println( " *** *** **Q " );
System.out.println( " 1 2 3 " );
System.out.println( " " );
}
}
}
Picture of the output