Assignment 49: Gender Game
Code
/// Name: Ryan McAteer
/// Period: 5
/// Program Name: Gender Game
/// File Name: Assignment49.java
/// Date Finished: 11/2/15
import java.util.Scanner;
class Assignment49
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String gender, firstName, lastName, married;
int age;
System.out.print( "Hello, what is your gender (M or F): " );
gender = keyboard.next();
System.out.print( "First Name: " );
firstName = keyboard.next();
System.out.print( "Last Name: " );
lastName = keyboard.next();
System.out.print( "Age: " );
age = keyboard.nextInt();
if ( gender.equals("F") && age < 20 )
{
System.out.println( "Then I shall call you " + firstName + " " + lastName + "." );
}
if ( gender.equals("F") && age >= 20 )
{
System.out.println( "Are you married, " + firstName + " (Y or N)?" );
married = keyboard.next();
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 + "." );
}
}
if ( gender.equals("M") && age < 20 )
{
System.out.println( "Then I shall call you " + firstName + " " + lastName + "." );
}
if ( gender.equals("M") && age >= 20 )
{
System.out.println( "Are you married, " + firstName + " (Y or N)?" );
married = keyboard.next();
if ( married.equals("Y") )
{
System.out.println( "Then I shall call you Mr. " + lastName + "." );
}
else if ( married.equals("N") )
{
System.out.println( "Then I shall call you Master " + lastName + "." );
}
}
}
}
Picture of the output