Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment is to give you practice using enums, string variables, and string functions. In order to get full credit for the program you must

This assignment is to give you practice using enums, string variables, and string functions. In order to get full credit for the program you must use these three topics.

You are to write a program that will read a series of names of people from a data file that has been created with extra blank spaces and reformat the names into a standardized format.

The datafile is MP6Names.txt. It is arranged with the information for one person on each line. The first character on the line will be either M or F indicating the gender of the person, and the second character will be either M, S, or D indicating married, single or divorced. You may assume that there will be no bad data here. The remainder of the line is the persons name in the form:

Last_name, First_name Middle_Initial.

Note that there will always be a comma immediately after the last name and, if the person has middle initial, it will always be followed by a period. However, there could be any number of blank spaces in between each part of the name and some people do not have middle initial.

Your task is to clean up the name and print it out in the standard format, e.g. Mr. Bill T. Jones with the appropriate title and exactly one space between each part of the name.

You are REQUIRED to use functions, enums, string variables and string functions in the solution to this problem. Define an enum for the Marital Status of the person (with the values SINGLE, MARRIED and DIVORCED) and write a function that reads in the character from the file and returns the appropriate enum value.

Read the name from the file into a string variable and write another function that uses the functions of the string class (e.g. find(), substr() etc.) to clean up the name and create a new string variable containing the name in the new format.

Finally, add the appropriate title to the name and print it out. All males will have the title Mr. married females will have Mrs. and single or divorced females will have Ms.

Continue doing this until the end of file is reached. Your output must include the original name as read from the file followed by the new name in the standardized format. For formatting purposes you may assume that no name will have more than 30 characters.

This is just a SUGGESTED method and for each step you may want to include output for debugging purposes to insure that your program is working correctly. Feel free to design your own modules as you like. A sample output from the first few lines of the data file follows:

Original name Standardized name Bach, Johann S. Mr. Johann S. Bach Curie, Marie A. Mrs. Marie A. Curie Parker, Alice M. Ms. Alice M. Parker

The following is copied from the MP6Names text file. Code MUST be in C++ and MUST utilize the .txt file as copied below! Odd spacing is (unfortunately) on purpose.

MS Bach, Johann S. FMCurie, Marie A. FS Parker, Alice M. FD Meir,Golda T. MDRobeson, Paul MM Ashe, Arthur FM Tubman, Harriet A. MSBraille,Louis 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions