Question: Write a function (named LastnameFirstname). IN C++that takes a multiline string and returns a string with the names reformatted. The parameter will have names written

Write a function (named "LastnameFirstname"). IN C++that takes a multiline string and returns a string with the names reformatted.

The parameter will have names written "Firstname Lastname" one per line, but the returned string should have each name written as "Lastname, Firstname". Note, the input string have have additional whitespace.

example input and expected output:

Write a function (named "LastnameFirstname"). IN C++that takes a multiline string and

INPUT OF THE TEST CASE X i #include ovou WN 3 std::string input = "Josh Richard Nahum Adam Driver Catherine Zeta Jones" ; std::string expected = "Nahum, Josh Richard Driver, Adam Jones, Catherine Zeta "; 5 ASSERT_EQ (LastnameFirstname (input), expected); std::string input2 = " Josh Richard Luis Nahum Douglas Adams John Quincy Adams "; std::string expected2 = "Nahum, Josh Richard Luis Adams, Douglas Adams, John Quincy "; ASSERT_EQ(LastnameFirstname (input2), expected2)

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!