Assignment #59
Code
/// Name: Ian Stanko
/// Period: 5
/// Program Name: ThreeCardMonte
/// File Name: ThreeCardMonte.java
/// Date Finished: 11/25/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 guess, card;
card = 1 + r.nextInt(3);
System.out.println( "You slide up to Fast Ian'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 " );
System.out.print( ">" );
guess = keyboard.nextInt();
if (card==1)
{
if ( guess == card )
{
System.out.println( "You nailed it! Fast Ian relectuantly hands over you winings, scowling." );
System.out.println( " AA ## ## " );
System.out.println( " AA ## ## " );
System.out.println( " 1 2 3 " );
}
else
{
System.out.println( "Ha Piere wins again! The ace was number " + card );
System.out.println( " AA ## ## " );
System.out.println( " AA ## ## " );
System.out.println( " 1 2 3 " );
}
}
else if (card==2)
{
if (guess==card)
{
System.out.println( "You nailed it! Fast Ian relectuantly hands over you winings, scowling." );
System.out.println( " ## AA ## " );
System.out.println( " ## AA ## " );
System.out.println( " 1 2 3 " );
}
else
{
System.out.println( "Ha Piere wins again! The ace was number " + card );
System.out.println( " ## AA ## " );
System.out.println( " ## AA ## " );
System.out.println( " 1 2 3 " );
}
}
else if (card==3)
{
if (guess==card)
{
System.out.println( "You nailed it! Fast Ian relectuantly hands over you winings, scowling." );
System.out.println( " ## ## AA " );
System.out.println( " ## ## AA " );
System.out.println( " 1 2 3 " );
}
else
{
System.out.println( "Ha Piere wins again! The ace was number " + card );
System.out.println( " ## ## AA " );
System.out.println( " ## ## AA " );
System.out.println( " 1 2 3 " );
}
}
}
}
Picture of the output