Assignemnt #49 and Gender Game
Code
///Name: Ben Borglin
///Period: 6
///Program Name: Gender Game
///File Name: GenderGame.java
///Date Finished: 10/6/15
import java.util.Scanner;
public class GenderGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String gender, first, last, married;
int age;
System.out.print("What is your gender? (M or F)");
gender = keyboard.next();
System.out.print("First Name:");
first = keyboard.next();
System.out.print("Last Name:");
last = keyboard.next();
System.out.print("Age:");
age = keyboard.nextInt();
System.out.println(" ");
if (gender.equals("F"))
{
if (age > 20)
{
System.out.println("Are you married, " + first + " (y or no)?");
married = keyboard.next();
if (married.equals("y"))
{
System.out.println("Then I shall call you ");
}
else if (married.equals("no"))
{
System.out.println("Then I shall call you Ms. " + last );
}
}
else if (age < 20)
{
System.out.println("Then I shall call you " + first + " " + last );
}
}
else if (gender.equals("M"))
{
if (age > 20)
{
System.out.println("Then I shall call you Mr. " + last);
}
else if (age < 20)
{
System.out.println("Then I shall call you " + first + " " + last);
}
}
}
}
Picture of the output