Assignment #49 and Gender Game

Code


  /// Name: Tim Chuang
/// Period: 7
/// Program Name: Gender Game
/// File Name: GenderGame.java
/// Date Finished: 12/1/2015

import java.util.Scanner;

class GenderGame
{
      public static void main(String[] args) 
      {
            
           Scanner keyboard = new Scanner(System.in);
           
           String gender, firstName, lastName, married;
           int age;
           
          System.out.print( " Whats ur gender?(M orF): ");
          gender = keyboard.next();
          System.out.print( " First name: " );
          firstName = keyboard.next();
          System.out.print( " Last name: " );
          lastName = keyboard.next();
          System.out.print( "Age: " );
           age = keyboard.nextInt();
           
           if ( gender.equals("F") && age < 20 )
           {
               System.out.println( "Then I'll call you " + firstName + " " + lastName + "." );
           }
           if ( gender.equals("F") && age >= 20 )
           {
               System.out.println( "Are you married " + firstName + " (Y or N)?" );
               married = keyboard.next();
               if ( married.equals("Y") )
               {
                   System.out.println( "Then I'll call you Mrs. " + lastName + "." );
               }
               else if ( married.equals("N") )
               {
                   System.out.println( "Then I'll call you Ms. " + lastName + "." );
               }
           }
           if ( gender.equals("M") && age < 20 )
           {
               System.out.println( "Then I'll call you " + firstName + " " + lastName + "." );
           }
           if ( gender.equals("M") && age >= 20 )
           {
               System.out.println( "Are you married, " + firstName + " (Y or N)?" );
               married = keyboard.next();
               if ( married.equals("Y") )
               {
                   System.out.println( "Then I'll call you Mr. " + lastName + "." );
               }
               else if ( married.equals("N") )
               {
                   System.out.println( "Then I'll call you Mr. " + lastName + "." );
               }
           }
      }
}
   

Picture of the output

Assignment 49