Assignemnt #59 Three Card Monte
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: Three Card Monte
///File Name: TCM.java
///Date: 11/16/2015
import java.util.Scanner;
import java.util.Random;
public class TCM
{
public static void main ( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int cup, guess;
cup = 1 + r.nextInt(3);
System.out.println("You slide up to Fast Eddie's cup table and plop down your cash.");
System.out.println("He glances at you out of the corner of his eye and starts moving the cups.");
System.out.println("He stops moving them.");
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");
System.out.println("");
guess = keyboard.nextInt();
if(guess==cup)
System.out.println("You nailed it! Fast Eddie reluctantly hands over your winnings, scowling.");
else
System.out.println("Ha! Fast Eddie wins again! The ball was in cup number " + cup + ".");
System.out.println("");
if(cup==1)
{
System.out.println("");
System.out.println(" || || ||");
System.out.println(" | | | | | |");
System.out.println(" O 2 3");
}
System.out.println("");
if(cup==2)
{
System.out.println("");
System.out.println(" || || ||");
System.out.println(" | | | | | |");
System.out.println(" 1 O 3");
}
System.out.println("");
if(cup==3)
{
System.out.println("");
System.out.println(" || || ||");
System.out.println(" | | | | | |");
System.out.println(" 1 2 O");
}
}
}
Picture of the output