Assignemnt #59
Code
///Name: Joshua Bautista
///Period: 6
///Project Name: Three Card Monte
///File Name: ThreeCardmonte.java
///Date: 1/7/2016
ptureimport java.util.Scanner;
import java.util.Random;
public class ThreeCardMonte
{
public static void main( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int choice, x;
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();
System.out.println(" Which one is the ace? ");
System.out.println();
System.out.println(" ## ## ## ");
System.out.println(" ## ## ## ");
System.out.println(" 1 2 3 ");
choice = keyboard.nextInt();
if ( choice == 1 && x == 1 )
{
System.out.println(" You nailed it! Fast Eddie reluctantly hands over your wining, scowling. ");
System.out.println(" AA ## ## ");
System.out.println(" AA ## ## ");
System.out.println(" 1 2 3 ");
}
if ( choice == 2 && x == 2 )
{
System.out.println(" You nailed it! Fast Eddie reluctantly hands over your wining, scowling. ");
System.out.println(" ## AA ## ");
System.out.println(" ## AA ## ");
System.out.println(" 1 2 3 ");
}
if ( choice == 3 && x == 3 )
{
System.out.println(" You nailed it! Fast Eddie reluctantly hands over your wining, scowling. ");
System.out.println(" ## ## AA ");
System.out.println(" ## ## AA ");
System.out.println(" 1 2 3 ");
}
else if ( choice != x && x == 1 )
{
System.out.println(" Ha! Fast Eddie wins again! The ace was card number " + x );
System.out.println(" AA ## ## ");
System.out.println(" AA ## ## ");
System.out.println(" 1 2 3 ");
}
else if ( choice != x && x == 2 )
{
System.out.println(" Ha! Fast Eddie wins again! The ace was card number " + x );
System.out.println(" ## AA ## ");
System.out.println(" ## AA ## ");
System.out.println(" 1 2 3 ");
}
else if ( choice != x && x == 3 )
{
System.out.println(" Ha! Fast Eddie wins again! The ace was card number " + x );
System.out.println(" ## ## AA ");
System.out.println(" ## ## AA ");
System.out.println(" 1 2 3 ");
}
}
}
Picture of the output