Assignment 49, Gender Game
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: Gender Game
///File Name: Gendergame.java
///Date Finshed: 11/18/15
import java.util.Scanner;
public class Gendergame
{
public static void main (String[] args)
{
Scanner siri = new Scanner (System.in);
String sex, first, last, married;
int age;
System.out.print("What is your gender? M or F?");
sex = siri.next();
System.out.print("First name: ");
first = siri.next();
System.out.print("Last name: ");
last = siri.next();
System.out.print("Age: ");
age = siri.nextInt();
if (age <= 20)
System.out.println("Hello " + first+ " " + last );
else if (age > 20 && sex.equals("F"))
{
System.out.print("Are you married? Y or N? ");
married = siri.next();
if ( married.equals("Y"))
{
System.out.println("Hello Mrs. " + last);
}
else if (married.equals("N"))
{
System.out.println("Hello Miss " + first);
}
if (age > 20 && sex.equals("M"))
System.out.println("Hello Mr. " +last);
}
}
}
Picture of the output