Assignemnt #59 and Three-Card Monte
Code
///Name: Dakota Donahue
///Period: 5
///Project Name: Three-Card Monte
///File Name:ThreeCardMonte.java
///Date: 12/4/2015
import java.util.Scanner;
import java.util.Random;
public class ThreeCardMonte
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int guess;
int x = 1 + r.nextInt(3);
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( "\n Which one is the ace? " );
System.out.println( "\n\t##\t##\t##" );
System.out.println( "\n\t##\t##\t##" );
System.out.println( "\n\t##\t##\t##" );
System.out.println( "\n\t1 \t2 \t3\n" );
guess = keyboard.nextInt();
if ( x == 1 )
{
if ( guess == 1 )
{
System.out.println( "\n You nailed it! Eddie hands over your winnings reluctantly. " );
System.out.println( "\n\tAA\t##\t##" );
System.out.println( "\n\tAA\t##\t##" );
System.out.println( "\n\tAA\t##\t##" );
System.out.println( "\n\t1 \t2 \t3\n" );
}
else if ( guess != 1 )
{
System.out.println( "\n You guessed wrong, the ace was number " + x );
System.out.println( "\n\tAA\t##\t##" );
System.out.println( "\n\tAA\t##\t##" );
System.out.println( "\n\tAA\t##\t##" );
System.out.println( "\n\t1 \t2 \t3\n" );
}
else
{
System.out.println( "\n That wasn't one of your options. " );
}
}
else if ( x== 2 )
{
if ( guess == 2 )
{
System.out.println( "\n You nailed it! Eddie hands over your winnings reluctantly. " );
System.out.println( "\n\t##\tAA\t##" );
System.out.println( "\n\t##\tAA\t##" );
System.out.println( "\n\t##\tAA\t##" );
System.out.println( "\n\t1 \t2 \t3\n" );
}
else if ( guess != 2 )
{
System.out.println( "\n You guessed wrong, the ace was number " + x );
System.out.println( "\n\t##\tAA\t##" );
System.out.println( "\n\t##\tAA\t##" );
System.out.println( "\n\t##\tAA\t##" );
System.out.println( "\n\t1 \t2 \t3\n" );
}
else
{
System.out.println( "\n That wasn't one of your options. " );
}
}
else if ( x == 3 )
{
if ( guess == 3 )
{
System.out.println( "\n You nailed it! Eddie hands over your winnings reluctantly. " );
System.out.println( "\n\t##\t##\tAA" );
System.out.println( "\n\t##\t##\tAA" );
System.out.println( "\n\t##\t##\tAA" );
System.out.println( "\n\t1 \t2 \t3\n" );
}
else if ( guess != 3)
{
System.out.println( "\n You guessed wrong, the ace was number " + x );
System.out.println( "\n\t##\t##\tAA" );
System.out.println( "\n\t##\t##\tAA" );
System.out.println( "\n\t##\t##\tAA" );
System.out.println( "\n\t1 \t2 \t3\n" );
}
else
{
System.out.println( "\n That wasn't one of your options. " );
}
}
}
}