Add two new methods to the Name class: public String getNormalOrder() Returns th
ID: 3875550 • Letter: A
Question
Add two new methods to the Name class: public String getNormalOrder() Returns the person's name in normal order, with the first name followed by the middle initial and last name. For example, if the first name is "John", the middle initial is 'Q', and the last name is "Public", this method returns "John Q. Public". public String getReverseOrder() Returns the person's name in reverse order, with the last name preceding the first name and middle initial. For example, if the first name is "John", the middle initial is 'Q', and the last name is "Public", this method returns "Public, John Q.". (You don't need to write the class header or declare the fields; assume that this is already done for you. Just write your two methods' complete code in the box provided.)Explanation / Answer
public String getNormalOrder()
{
return ""+this.first_name+" "+mid_initial+". "+this.last_name;
// here if you place this function inside Name class ,it's your wish to place
// 'this.' before these members
// here 'this' represents present class's data members
}
public String getReverseOrder()
{
return ""+this.last_name+", "+this.first_name+" "+mid_initial+".";
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.