Assignemnt #49, Gender Game
Code
/// Name: Alex Pinder
/// Period: 5
/// Program Name: Gender Game
/// File Name: prog49.java
/// Date Complete: 11/30/15
import java.util.Scanner;
public class prog48
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String gender, firstName, lastName, marrage;
int age;
System.out.print( "What is your gender? (M or F or O) " );
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("M") );
{
if ( age < 20 )
{
System.out.println( "Then I shall call you " + firstName + " " + lastName + "." );
}
else
{
System.out.println( "Then I shall call you Mr. " + lastName + "." );
}
}
if ( gender.equals("F") )
{
if ( age > 19 )
{
System.out.print( "Are you married, " + firstName + "? ( y or n ) " );
marrage = keyboard.next();
if ( age > 19 && marrage.equals("y") )
{
System.out.println( "Then I shall call you Mrs. " + lastName + "." );
}
else if ( age > 19 && marrage.equals("n") )
{
System.out.println( "Then I shall call you Ms. " + lastName + "." );
}
else
{
System.out.println( "Then I shall call you " + firstName + " " + lastName + "." );
}
}
}
if ( gender.equals( "O" ) )
{
System.out.println( "Then I shall call you " + firstName + " " + lastName + "." );
}
}
}
Picture of the output