Assignment # 49 and Gender Game
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: GenderGame
/// File Name: GenderGame.java
/// Date: 11/18/2015
import java.util.Scanner;
public class GenderGame
{
public static void main(String[] args)
{
{
Scanner keyboard = new Scanner(System.in);
boolean isFemale, isMarried = false;
isFemale = false;
String FName, LName = "";
int age = 0;
System.out.print("What is your gender? M/F: ");
String input = keyboard.next();
switch (input)
{
case "F":
isFemale = true;
break;
case "M":
isFemale = false;
break;
default:
}
System.out.println();
System.out.print("First name: ");
FName = keyboard.next();
System.out.println();
System.out.print("Last name: ");
LName = keyboard.next();
System.out.println();
System.out.print("Age: ");
age = keyboard.nextInt();
if (isFemale & age >= 20)
{
System.out.println();
System.out.print("Are you married, " + FName + "? Y/N: ");
input = keyboard.next();
System.out.println();
switch (input)
{
case "Y":
System.out.println("Then I should call you Mrs. " + LName+".");
break;
case "N":
System.out.println("Then I should call you Ms. " + LName+".");
break;
default:
}
} else if (age > 20 & !isFemale) System.out.println("Then I should call you Mr. " + LName+".");
else System.out.println("Then I should call you " + FName + " " + LName+".");
}
}
}
Picture of the output