Assignemnt #59 and Three Card Monte
Code
///Name: Ben Borglin
///Period: 6
///Program name: Three Card Monte
///file name: ThreeCardMonte.java
///Date Finsihed: 10/19/15
import java.util.Random;
import java.util.Scanner;
public class ThreeCardMonte
{
public static void main( String[] args)
{
int guess;
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int ball = 1 + r.nextInt(3);
System.out.println("You call up your homie, Joey, and he is having a bomb party going on right now.");
System.out.println("He invites you over to play some games.");
System.out.println("The first of one game is for you to guess which cup the ball is under.");
System.out.println("He lays down the 3 cups and shuffles the ball.");
System.out.println(" ");
System.out.println("Which one has the ball inside?");
System.out.println(" ");
System.out.println(" | | | | | |");
System.out.println(" | | | | | |");
System.out.println(" |__| |__| |__|");
System.out.println(" 1 2 3 ");
System.out.println(" ");
System.out.println(" ");
System.out.print(">");
guess = keyboard.nextInt();
if (guess == ball)
{
System.out.println("WOw.. Nice guess.");
}
else if (guess != ball )
{
System.out.println("Ha! Youuuu lose!");
}
System.out.println("The ball was really in cup " + ball);
if (ball == 1)
{
System.out.println(" ");
System.out.println(" | | | | | |");
System.out.println(" | | | | | |");
System.out.println(" |_X_| |_0_| |_0_|");
System.out.println(" 1 2 3 ");
System.out.println(" ");
}
else if (ball == 2)
{
System.out.println(" ");
System.out.println(" | | | | | |");
System.out.println(" | | | | | |");
System.out.println(" |_0_| |_X_| |_0_|");
System.out.println(" 1 2 3 ");
System.out.println(" ");
}
else if (ball == 3)
{
System.out.println(" ");
System.out.println(" | | | | | |");
System.out.println(" | | | | | |");
System.out.println(" |_0_| |_0_| |_X_|");
System.out.println(" 1 2 3 ");
System.out.println(" ");
}
}
}
Picture of the output