Question: C++ please HOMEWORK #30-Name Parser Write a program that reads a person's name in the following format: first name, middle name or middle initial, and
HOMEWORK #30-Name Parser Write a program that reads a person's name in the following format: first name, middle name or middle initial, and last name. The program should then output the name in the following format lastName, firstName middleInitial. For example, the input: Mary Tylor Moore should produce the output Moore, Mary T The input: Mary T. Moore Should also produce the output: Moore, Mary T Your program should work identically in both cases-meaning that it should place a period after the middle initial even if the input does not contain a period. Your program should also allow for users who give no middle name or middle initial In that case, the output contains no initial. For example, the input: Mary Moore should produce the output Hoore, Mary Specifications: The program must use string objects via the string library, opposed to using C-based character arrays. You may use either the extraction operator >> or the getline) function, as appropriate. If you execute the program, the following information should be displayed -main.o Enter a name: Mary Tyler Moore Abbreviated: Moore, Mary T -main.o Enter a name: Mary T. Moore Abbreviated: Moore, Mary T -> main.o Enter a name: Mary Moore Abbreviated: Moore, Mary
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
