Assignemnt #49: Using Gender to Determine Title
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: GenderGame
/// File Name: GenderGame.java
/// Date Finished: 10/29/2015
import java.util.Scanner;
public class GenderGame
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int age;
String gender, firstName, lastName, maritial, Title;
System.out.println( "What is your gender? (Male or Female) " );
gender = keyboard.next();
System.out.println ( "First name: " );
firstName = keyboard.next();
System.out.println ( "Last name: " );
lastName = keyboard.next();
System.out.println( "Age: " );
age = keyboard.nextInt();
if (( age >= 20) && (gender.equals("Male")) )
{
Title = "Mr.";
System.out.println();
System.out.println( "Then I shall call you " + Title + " " + lastName );
}
if (age < 20 )
{
System.out.println();
System.out.println( "Then I shall call you " + firstName+ " " + lastName );
}
if (( age >= 20) && (gender.equals("Female")) )
{
System.out.println ( "Are you married, " + firstName + " yes or no? " );
maritial = keyboard.next();
if (maritial.equals("yes"))
{
Title = "Mrs.";
System.out.println();
System.out.println( "Then I shall call you " + Title + " " + lastName );
}
else
{
Title = "Ms.";
System.out.println();
System.out.println( "Then I shall call you " + Title + " " + lastName );
}
}
}
}
Picture of the output