Assignemnt #49 and Gender Game
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Gender Game
/// File Name: GenderGame.java
/// Date Finished: 11/3/2015
import java.util.Scanner;
public class GenderGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String fName, lName, gender, married;
int age;
System.out.print("What is your gender (M or F): ");
gender = keyboard.next();
System.out.print("First name: ");
fName = keyboard.next();
System.out.print("Last name: ");
lName = keyboard.next();
System.out.print("Age: ");
age = keyboard.nextInt();
System.out.println(" ");
if ( gender.equals("F") && age >= 20 )
{
System.out.print("Are you married, " + fName + " (y or n)? ");
married = keyboard.next();
System.out.println(" ");
if ( married.equals("y"))
{
System.out.println("Then I shall call you Mrs. " + lName + ".");
}
else if ( married.equals("n"))
{
System.out.println("Then I shall call you Ms. " + lName + ".");
}
}
else if ( age >= 20 )
{
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