Assignment #49 and Gender Game
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Gender Game
/// File Name: GenderGame.java
/// Date Finished: 10/2/2015
import java.util.Scanner;
public class GenderGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String gender, last, first, married;
int age;
System.out.print( "What is your gender (M or F): " );
gender = keyboard.next();
System.out.print( "First name: " );
first = keyboard.next();
System.out.print( "Last name: " );
last = keyboard.next();
System.out.print( "Age: " );
age = keyboard.nextInt();
System.out.println( " " );
if ( age < 20 )
{
System.out.println( "Then I shall call you " + first + " " + last + "." );
}
else if ( gender.equals("M") )
{
System.out.println( "Then I shall call you Mr. " + last + "." );
}
else
{
System.out.print( "Are you married, " + first + " (y or n)? " );
married = keyboard.next();
if ( married.equals("y") && gender.equals("F") )
{
System.out.println( "Then I shall call you Mrs. " + last + "." );
}
else
{
System.out.println( "Then I shall call you Ms. " + last + "." );
}
}
}
}
Picture of the output