import java.util.Scanner; public class GenderGame { public static void main(String[] args) { //System Objects Scanner keyboard = new Scanner(System.in); //Variables String Male = "Male"; String Female = "Female"; String Married; System.out.print("What is your gender (male or female):"); String gender = keyboard.nextLine(); System.out.print("Firstname:\t"); String name = keyboard.nextLine(); System.out.print("Last Name:\t"); String lastName = keyboard.nextLine(); System.out.print("Age:\t\t"); int age = keyboard.nextInt(); if (gender.equalsIgnoreCase(Female) && age >= 20) { System.out.print("Are you married, " + name + "? (yes or no)"); Married = keyboard.next(); if (Married.equalsIgnoreCase("yes")) System.out.print("Then I shall call you Mrs. " + lastName + "."); }else{ System.out.print("Then I shall call you " + name + " " + lastName + "."); if (gender.equalsIgnoreCase(Male) && age >= 20) System.out.print("Then I shall call you Mr. " + lastName + "."); if (gender.equalsIgnoreCase(Male) && age < 20) System.out.print("Then I shall call you " + name + " " + lastName + "."); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)