Assignment #59: Three Card Monte
Code
/// Name: Kiran O'Farrell
/// Program Name: Three Card Monte
/// File Name: ThreeCardMonte.java
/// Date Completed: 12/3/15
import java.util.Random;
import java.util.Scanner;
public class ThreeCardMonte {
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int ace = (r.nextInt(3) + 1);
int guess;
System.out.println("#### #### ####");
System.out.println("#### #### ####");
System.out.println("#### #### ####");
System.out.println("#### #### ####");
System.out.println(" 1 2 3 ");
System.out.println("Which card is the ace?");
guess = keyboard.nextInt();
if (guess == ace) {
System.out.println("Congratulations! You guessed right.");
}
else {
System.out.println("Sorry! You guessed wrong.");
}
}
}
Picture of the output