Program #59

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Three Card Monte
    /// File Name: Monte.java
    /// Date Finished: 12/2/2015 public class Monte

        import java.util.Random;
        import java.util.Scanner;
          
          public class Monte
          {
              public static void main( String[] args )
              {
                  Random r = new Random();
                  Scanner keyboard = new Scanner(System.in);
                  int guess, number;
                  number = 1 + r.nextInt(2);
                  
                  System.out.println( "You slide up to Fast Eddie's card table and plop down your cash. " );
                  System.out.println( "He glances at you 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( "    ## ## ## " );
                  System.out.println( "    1  2  3 " );
                  System.out.println();
                  System.out.print( "> " );
                  guess = keyboard.nextInt();
                  
                  System.out.println();
                  
                  if ( number == guess )
                  {
                      System.out.println( "You nailed it! Fast Eddie reluctantly hands over your winnings, scowling. " );
                  }
                  else if ( number != guess )
                  {
                      System.out.println( "Ha! Fast Eddie wins again! The ace was card number " + number + "." );
                  }
                  if ( number == 1 )
                  {
                      System.out.println( "    AA ## ## " );
                      System.out.println( "    AA ## ## " );
                  }
                  else if ( number == 2 )
                  {
                      System.out.println( "    ## AA ## " );
                      System.out.println( "    ## AA ## " );
                  }
                  else if ( number == 3 )
                  {
                      System.out.println( "    ## ## AA " );
                      System.out.println( "    ## ## AA " );
                  }
                  
                  System.out.println( "    1  2  3 " );
            }
        }
 
             
    

Picture of the output

Assignment 59