Assignment #59

Code

    /// Name: Jonathan Stine
    /// Period: 5
    /// Program Name: Three Card Monte
    /// File Name: Monte.java
    /// Date Finished: 1/19/16
    
    import java.util.Scanner;
    import java.util.Random;
    
    public class Monte {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            Random r = new Random();
            
            int door = 1 + r.nextInt(3);
            
            System.out.println( "You are on a gameshow." );
            System.out.println( "You have to guess which of three doors has a car behind it." );
            System.out.println( "If you guess right, you win a new car." );
            System.out.println();
            System.out.println( "Which door is it?" );
            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.println( "-------  -------  -------" );
            System.out.println();
            System.out.print( "> " );
            int choice = keyboard.nextInt();
            System.out.println();
            
            if ( choice == door ) {
                System.out.println( "We have a winner!" );
            }
            
            else if ( choice > door ) {
                System.out.println( "SUCKER. YOU LOOSE!" );
            }
            
            else if ( choice < door ) {
                System.out.println( "The car is all mine! You get nada!" );
            }
            
            else {
                System.out.println( "How were you not aborted?" );
            }
            
            
            System.out.println();
            
            if ( door == 1 ) {
                System.out.println( "-------  -------  -------" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "| car |  |  2  |  |  3  |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "-------  -------  -------" );
            }
            
            else if ( door == 2 ) {
                System.out.println( "-------  -------  -------" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|  1  |  | car |  |  3  |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "-------  -------  -------" );
            }
            
            else if ( door == 3 ) {
                System.out.println( "-------  -------  -------" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|  1  |  |  2  |  | car |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "|     |  |     |  |     |" );
                System.out.println( "-------  -------  -------" );
            }
        }
    }
                  
    
 
    

Code Output