Assignemnt #49 Gender Game
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: Gender Game
///File Name: GG.java
///Date: 11/5/2015
import java.util.Scanner;
public class GG
{
public static void main( String[] args)
{
Scanner keyboard = new Scanner(System.in);
String name, lastName, gender, married;
int age;
System.out.print("What is your gender (M or F): ");
gender = keyboard.next();
System.out.print("First Name: ");
name = keyboard.next();
System.out.print("Last Name: ");
lastName = keyboard.next();
System.out.print("Age: ");
age = keyboard.nextInt();
System.out.println("");
if(gender.equals("M"))
{
if(age>=20)
{
System.out.println("Then I shall call you Mr. " + lastName + ".");
}
else
{
System.out.println("Then I shall call you " + name + " " + lastName + ".");
}
}
else if(gender.equals("F"))
{
if(age>=20)
{
System.out.print("Are you married, " + name + " (y or n)?");
married = keyboard.next();
System.out.println("");
if(married.equals("y"))
{
System.out.println("Then I shall call you Mrs. " + lastName + ".");
}
else if(married.equals("n"))
{
System.out.println("Then I shall call you Ms. " + lastName + ".");
}
else
{
System.out.print("Wrong input");
}
}
else if(age<20)
{
System.out.println("Then I shall call you " + name + " " + lastName + ".");
}
}
else
{
System.out.print("Wrong input.");
}
}
}
Picture of the output