Gender

Code

import java.util.Scanner;

public class Gender
{
	public static void main( String[] args )
	{
		Scanner keyboard = new Scanner(System.in);
        
        String name1, g, name2, m;
        int age;
        
        System.out.println( " what is your gender m or f " );
        g = keyboard.next();
            
        System.out.println( " First name " );
        name1 = keyboard.next();
        
        System.out.println( " Last name " );
        name2 = keyboard.next();
        
        System.out.println( " Age " );
        age = keyboard.nextInt();
        
        System.out.println( " are you married y or n " );
        m = keyboard.next();
        
        if ( g.equals("m") && age > 17 )
        {
            System.out.println( "then i will call you Mr." + name2 );
        }
        if ( g.equals("m") && age < 18 )
        {
            System.out.println( "then i will call you ." + name1 );
        }
        if ( g.equals("f") && age > 17 )
        {
            System.out.println( "then i will call you Mrs." + name2 );
        }
        if ( g.equals("f") && age < 18 )
        {
            System.out.println( "then i will call you ." + name1 );
        }
    }
}

Gender

Assignment 49