PROGRAMMING AND CODE


Assignemnt #49

Code

/// Name: Justin Li
/// Period 7
/// Program Name: Gender Game
/// File Name: GenderGame.java
/// Date Finished: 9/23/15

import java.util.Scanner;

class GenderGame {
  
    public static void main(String[]args) {
      
        Scanner keyboard = new Scanner(System.in);
        
        String gender, first, last, married;
        int age;
        
        System.out.println("What is your gender?");
        gender = keyboard.next();
        
        System.out.println("What is your first name?");
        first = keyboard.next();
        
        System.out.println("What is your last name?");
        last = keyboard.next();
        
        System.out.println("How old are you?");
        age = keyboard.nextInt();

        if (gender.equals("female")) {
            if (age >= 20){
                System.out.println("Are you married?");
                married = keyboard.next();
                if (married.equals("yes")){
                    System.out.println("I shall call you Mrs." + last);
                }
                else if (married.equals("no")){
                    System.out.println("I shall call you Ms." + last);
                
                }
            }
            else if (age < 20){
                System.out.println("I shall call you " + first + " " + last);
            }
            
        }
        else if (gender.equals("male")) {
            if (age >= 20) {
                System.out.println("I shall call you Mr." + last);
            }
            else if (age < 20) {
                System.out.println("I shall call you " + first + " " + last);
            }
            else {
                System.out.println("WHAT??");
            }
        }
        else {
            System.out.println("WHAT??");
        }
          
          
    }
}
    

Picture of the output

Assignment 1