Assignemnt #49

Code

///colin hinton
///5th period
///Gender Game
///GenderGame.java
///10/20/2015

import java.util.Scanner;

class GenderGame
{
    public static void main (String [] args)
    {
        Scanner keyboard = new Scanner(System.in);
        
        int age; 
        String first, last, gender, marrage;
        
        System.out.println("What is your gender (M or F): ");
        gender = keyboard.next();
        System.out.println("First name: ");
        first = keyboard.next();
        System.out.println("Last name: ");
        last = keyboard.next();
        System.out.println("Age: ");
        age = keyboard.nextInt();
        System.out.println();
        
        if (age < 20)
        {
            
            System.out.println("Then i shall call you " + first + " " + last + ".");
        }
        else if (age >= 20)
        {
            if (gender.equals("M"))
            {
                System.out.println("Then i shall call you Mr. " + last + ".");
            }
            else if (gender.equals("F"))
            {
                System.out.println("Are you married, " + first + " (y or n)");
                marrage = keyboard.next();
                
                if (marrage.equals("y"))
                {
                    System.out.println("Then i shall call you Mrs. " + last + ".");
                }
                else if (marrage.equals("n"))
                {
                    System.out.println("Then i shall call you Ms. " + last + ".");
                }
                else
                {
                    System.out.println("give up");
                } 
            }
            else
            {
                System.out.println("give up");
            }    
        }
        else 
        {
            System.out.println("give up");
        }    
    
    
    
    }
    
}
    



    

Picture of the output

Assignment 1