The file containing your companies’ employee directory has been mysteriously rearranged. The order of entries is no longer logical and it is very difficult to read. Fortunately, the pattern of rearrangement was the same for each entry. Therefore, writing a program to process the old directory and create a new directory is much easier.

Each entry for the new directory is to consist of a person’s full name with title, their home address and three phone numbers. The persons name will be on the first line and the address will consist of two lines. The first line of the address is the number and street, and the second line is the city, state and zipcode+4. The three phone numbers appear in the order of home, cell and work. Each number appears on its own line and is followed by the proper designator of (H) for home, (C) for cell and (W) for work. These designators are not present in the jumbled directory, and they must be added to the numbers in the new directory.

To help organize all the variables required to hold the information, structures are to be used with the program. You have decided to use four structure declarations in a hierarchical formation. The top structure has three members and each of these members is a structure. The three structures required by the top structure are: one for holding an employees name (title, first name and last name), one for holding the employees address (number and street, city and state, and zip code (5+4 version)), and one for holding the phone numbers (home, work and cell). All members of these structures are string variables. Strings are required for the phone number and zip codes due to the hyphen present in those values.

The program is to continually prompt for an input file to open until a valid filename is entered or the user enters ctrl-c to exit. After opening the input file, the output file is opened in the same manner as the input file. Once the input and output file are opened, the records (a record is the information for one employee) of the jumbled directory are read one record at a time and then transferred to the new directory. Therefore reading the jumbled directory and writing to the new directory occurs inside of a loop. A row of 60 asterisks is to separate the entries in the new directory (see the output by the sample solution).

Your program is to open the jumbled directory file for input, read information for one employee into the appropriate member fields of the structures then output the information from the structures to the output file (new directory) in the correct format. Reading the information for each employee is repeated until all information in the jumbled directory file has been read.

You can read the input file one time only.

Input File Information

The input file for this project will contain information in the order shown below. Comments are used to specify the data information, and these comments are not in the actual data file. Each data entry is contained on a single line. The first line of this file contains the Employee Directory name, and this name needs to be copied to the new output file for its first line.

Employee Directory for XYZ Corporation
Mr. // title of employee
123 Skipping Rock Lane // street address
652-555-0011 // cell phone number
Bowman // last name of employee
256-555-1234 // Home number
Huntsville, Alabama // city and state of address
Ronald // First name of employee
256-556-6799 // Work number
35899-0099 // Zip Code

Note that the street address line and the city and state line will have to be read using the getline function. All other inputs can be read using the getline function or with the extraction operator. If you mix the getline function in with the extraction operator, remember where the reading marker is placed after each of those reads. You may have to use the ignore function to move the reading marker past the new-line character at the end of a line.

Assumptions

You can assume the following facts: For non-empty input files, all information is complete and in the order specified.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.