String Name Occupation Parsing

Geoffrey Challen // 2023.7.0

Write a method name parseNameOccupation that accepts a single String in the following format:

  • "Aisha, a coder!"
  • "Felip, a doctor!"
  • "Gracie, a dog!"

Specifically, the input String has the following format: ", a !". (Gracie's one and only job is being a dog.) Note that the name will always be followed immediately by a comma, and the occupation by an exclamation point.

You should return a new String reformatted as follows: "My friend is a great !". So, given "Aisha, a coder!", you would return "My friend Aisha is a great coder!" Note that we have removed the comma but kept the exclamation point.

To complete this problem you will probably want to utilize the String methods split and substring.