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