Question: Complete the generateFormalName method so that you return the formal name (Mr. or Ms. + last name) given a full name and gender (Strings) as

Complete the generateFormalName method so that you return the formal name (Mr. or Ms. + last name) given a full name and gender (Strings) as parameters.

--You can assume a valid name & gender (any case allowed) is passed in. Example 1: ("Bob Smith", "MaLE") passed in should generate "Mr. Smith" Example 2: ("Maggie May", "feMALE") passed in should generate "Ms. May"

Tip 1: You are given a String formalName initialized to the empty String -- you will want to concatenate other Strings onto this to produce the full formalName.

Tip 2: Write your algorithm in English first.

Tip 3: Think of all of the methods at your disposal and which could be helpful.

Given Code:

public class StringPractice {

public String generateFormalName(String fullName, String gender) { String formalName = ""; //Insert your code here: return formalName; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!