Assignment #59 and Three Card Monte
Code
/// Name: Brendan Baird
/// Period: 6
/// Program Name: Three Card Monte
/// File Name: ThreeCardMonte.java
/// Date Finished: 11/3/2015
import java.util.Random;
import java.util.Scanner;
public class ThreeCardMonte
{
public static void main(String[] args)
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int x = 1 + r.nextInt(3);
int guess;
System.out.println("You sit down at the table, plop down all your candy bars. Jack shuffles the cards and lays 'em down nicely.");
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();
System.out.println();
if (guess == x)
System.out.println("You got it right! Jack hands over your winnings.");
else
System.out.println("Ha! Jack wins again! The ace was card number " + x + ".");
System.out.println();
if (x == 1)
{
System.out.println(" AA ## ##");
System.out.println(" AA ## ##");
System.out.println(" 1 2 3");
}
else if (x == 2)
{
System.out.println(" ## AA ##");
System.out.println(" ## AA ##");
System.out.println(" 1 2 3");
}
else if (x == 3)
{
System.out.println(" ## ## AA");
System.out.println(" ## ## AA");
System.out.println(" 1 2 3");
}
}
}
Picture of the output