Ask Question

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'

+3
Answers (1)
  1. 3 May, 21:15
    0
    public static String getNormalOrder (String fname, String lname, String init) {

    return fname+" "+init+" "+lname;

    }

    public static String getReversedOrder (String fname, String lname, String init) {

    return lname+" "+lname+" "+init;

    }

    Explanation:

    In java programming language, the two methods are written above

    The methods receive as parameters the fname, lname and init representing first name, last name and initials respectively

    The first method returns a concatenated string in the correct order as specified by the question

    The second method also returns the concatenated string as specified

    See a complete code below where all variables are declared and the methods are called

    public class ReversingNames {

    public static void main (String[] args) {

    String fname = "John";

    String lname = "Public";

    String init = "Q";

    //Call getNormalOder

    System. out. println (getNormalOrder (fname, lname, init));

    //Call getReversedOrder

    System. out. println (getReversedOrder (fname, lname, init));

    }

    public static String getNormalOrder (String fname, String lname, String init) {

    return fname+" "+init+" "+lname;

    }

    public static String getReversedOrder (String fname, String lname, String init) {

    return lname+" "+lname+" "+init;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Public String getNormalOrder () Returns the person's name in normal order, with the first name followed by the middle initial and last ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers