Assignemnt #49 and Gender Game
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: GenderGame
/// File Name: GenderGame.java
/// Date Finished: 12/2/2015
import java.util.Scanner;
public class GenderGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String gender, firstName, lastName, answer;
int age;
System.out.print( "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.print( "Are you married " + firstName + "? (y or n)? ");
answer = keyboard.next();
if ( answer.equals("y") )
{
System.out.println( "Then I shall call you Mrs. " + lastName + "." );
}
else if ( answer.equals("n") )
{
System.out.println( "Then I shall call you Ms. " + lastName + "." );
}
}
else if ( gender.equals( "m" ) && age >= 20 )
{
System.out.println( "Then I shall call you Mr. " + lastName + "." );
}
else if ( age < 20 )
{
System.out.println( "Then I shall call you " + firstName + " " + lastName + "." );
}
}
}
prog49.PNG