Assignemnt #49 and Gender Game
Code
///Name: Mark
///Period: 6
///Program Name: Gender Game
///File Name: gender.java
///Date finished: 10/13/15
import java.util.Scanner;
public class gender
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String fn, ln, yn="", mf;
int age;
System.out.print( "What is your gender? (M or F): " );
mf = keyboard.next();
System.out.print( "First Name: " );
fn = keyboard.next();
System.out.print( "Last Name: " );
ln = keyboard.next();
System.out.print( "Age: " );
age = keyboard.nextInt();
System.out.println( "" );
if (mf.equals("M"))
{
if(age < 20 )
{
System.out.println( "Then I shall call you " + fn + " " + ln + "." );
}
else
{
System.out.println( "Then I shall call you Mr. " + ln );
}
}
else if (mf.equals("F"))
{
if(age > 20 )
{
System.out.print( "Are you married? (y or n) " );
yn = keyboard.next();
System.out.println( "" );
}
if (yn.equals("y"))
{
System.out.println( "Then I shall call you Mrs. " + ln );
}
else if (yn.equals("n"))
{
System.out.println( "Then I shall call you Ms. " + ln );
}
else
{
System.out.println( "Then I shall call you " + fn + " " + ln );
}
}
}
}
Picture of the output