Assignment #49 Gender Game
Code
///Name: Ian Grant
///Period:5
///Project Name: Gender Game
///File Name:GenGame.java
///11/2/15
import java.util.Scanner;
public class GenGame
{
public static void main(String[] args)
{
String gen, fname, lname, mar;
int age;
Scanner stuff=new Scanner(System.in);
System.out.print("What is your gender (M OR F): ");
gen=stuff.next();
System.out.print("First name: ");
fname=stuff.next();
System.out.print("Last name: ");
lname=stuff.next();
System.out.print("Age: ");
age=stuff.nextInt();
if (gen.equals("M"))
{
if (age>=20)
System.out.println("Then I shall call you Mr. "+lname+".");
else
System.out.println("Then I shall call you "+fname+" "+lname+".");
}
else if (gen.equals("F"))
{
if (age>=20)
{
System.out.println("Are you married, "+fname+" (Y OR N)? ");
mar=stuff.next();
if (mar.equals("Y"))
System.out.println("Then I shall call you Mrs. "+lname+".");
else if(mar.equals("N"))
System.out.println("Then I shall call you Ms. "+lname+".");
}
}
}
}
Output