Assignment #59

Code

    /// Name: Mahima Choudhary
    /// Period: 6
    /// Program Name: Three Card Monte
    /// File Name: ThreeCardMonte.java
    /// Date Finished: 12/2/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 casino, plop down all your golden tokens. Mahi lays down 3 cards after shuffling them thoroughly.");
            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("Ha correct! Mahi hands over your golden tokens to go cash in.");
            else
                System.out.println("Mahi 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

Assignment 59