Write the method String convertName(String name) in Java that implements the following logic: Given a string in the form of "last_name,...
X1627: Convert name from last, first to first last
Write the method String convertName(String name) in Java that
implements the following logic: Given a string in the form of "last_name, first_name",
return a string of the form "first_name last_name." The last name and
first name may contain a space. If the last name has a space, then replace
the space with a hyphen ("-").
You can assume that there is always a comma
in name and that it is followed by 1 space.
You may consult the Java String class to help you solve this problem.
Examples:
convertName("Perez Quinones, Manuel") -> "Manuel Perez-Quinones"
Your Answer:
Feedback
Your feedback will appear here when you check your answer.