Assignemnt #49 and Gender Game
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: Gender Game
/// File Name: GenderGame.java
/// Date Finished: 12/2/2015
import java.util.Scanner;
public class GenderGame
{
public static void main(String[] args)
{
String fName, lName, answer2, answer1;
int age;
Scanner keyboard = new Scanner(System.in);
System.out.println("What is your Gender (M or F):");
answer1 = keyboard.next();
System.out.println("First name: ");
fName = keyboard.next();
System.out.println("Last name: ");
lName = keyboard.next();
System.out.println("Age: ");
age = keyboard.nextInt();
System.out.println();
if (answer1.equals("F") && age > 19)
{
System.out.println("Are you married " + fName + " (y or n)?");
answer2 = keyboard.next();
System.out.println();
if (answer2.equals("y"))
{
System.out.println("Then I shall call you Mrs. " + lName + ".");
}
if (answer2.equals("n"))
{
System.out.println("Then I shall call you Ms. " + lName + ".");
}
else if ( answer1.equals("M"))
System.out.println("Then I shall call you Mr. " + lName + ".");
}
else
System.out.println("Then I shall call you " + fName + " " + lName + ".");
}
}
Picture of the output