Assignment #49
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Gender Game
/// File Name: GenderGame.java
/// Date Finished: 1/19/16
import java.util.Scanner;
public class GenderGame {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
String gender, fName, lName, married;
int age;
System.out.print( "What is your gender (M or F): " );
gender = keyboard.next();
System.out.print( "First Name: " );
fName = keyboard.next();
System.out.print( "Last Name: " );
lName = keyboard.next();
System.out.print( "Age: " );
age = keyboard.nextInt();
System.out.println();
if ( gender.equals("F") && age >= 20 ) {
System.out.print( "Are you married, " + fName + " (y or n)? " );
married = keyboard.next();
System.out.println();
if ( married.equals("y") ) {
System.out.println( "Then I shall call you Mrs. " + lName + "." );
}
if ( married.equals("n") ) {
System.out.println( "Then I shall call you Ms. " + lName + "." );
}
}
if ( age < 20 ) {
System.out.println( "Then I shall call you " + fName + " " + lName + "." );
}
if ( gender.equals("M") && age >= 20 ) {
System.out.println( "Then I shall call you Mr. " + lName + "." );
}
}
}
Code Output