Question: In C + + , This program is going to make use of structured data. You are to come up with two structures; one for

In C++, This program is going to make use of structured data. You are to come up with two structures; one for an employee and one for a department. You must incorporate some kind of nested structure into your program. The goal of this program is to read a text file that is comma separated. The following fields will be in the text file: social security number, first name, last name, middle initial, city, state, age, gender, department id, department name, building letter, building floor, and department phone number. You are to read these fields into an array made of your structure. Use what you know to your advantage; we know that there are a set number of columns and we know that each column is separated by a comma. It is crucial that this is dynamic, I will be testing your program against 3 different text files to ensure that this is dynamic. Once the information is read in we will be able to perform some manipulation on the data. We will display a menu that has the following options: Display all employees, display the name of the oldest employee, display the building letter and floor for the computer science department, display all department names who are in building A, find an employee and list their information, and average age of employees who live in Michigan. Once one of these options is selected the screen will clear and the result will show. At this point the user will be able to enter in 0 to display the menu options again or -999 to exit the program. It is important to note that some of the menu options could show duplicate results, I do not want you to show duplicates (E.G. if more than one person works in a department in building A, we would list that department more than once. We do not want this.). You are not allowed to use any prebuilt functions to parse the data (E.G. istringstream), you must come up with your own algorithm for this.
Notes:
You must incorporate at least two functions. However, I highly recommend that you use more than two.
Be careful reading in fields that have spaces.
Be sure to know what value is being stored in what type of variable. You will most likely read everything in as a string. However, I want you to do math with ages so that needs to be stored as an integer.
You are allowed to make a global structure but that is the only global variable that you are allowed to use. NOTE: I am talking about the structure not the array
This must be dynamic, so looking at the text file and seeing the number of entries in my text file and making an array that large will not work.
There should be error checking on your menu options (Dont worry about if the user inputs a string, we just want a valid menu selection).
There will always be the same number of columns
The columns will always be in the same order
You can use .find() and .substr(). There will be an example that goes over these functions.
Output NEEDS to look like this:
EMPLOYEE INFORMATION WHATEVER COMPANY INC.
Display all employees
Display name of oldest employee
Display the building letter and floor for Computer Science department
Display department names who are in building A
Find an employee and list their information
Average age of employees who live in Michigan
Return to menu
-999. Exit the progam
Enter your selection ( for menu -999 to exit): 22
Enter your selection (99 for menu -999 to exit): 32
Enter your selection (99 for menu -999 to exit): EMPLOYEEB8
EMPLOYEE 01
EMPLOYEE 02
Option 2
oldest Employee Name
Abe, Rachel 0.
Age: 77
Enter your selection (6 for menu -999 to exit): Building: A floor: 13
Enter your selection (8 for menu -999 to exit):
Option 4
Building A Departments
Computer Science
Account ing
Enter your selection ( for menu -999 to exit):
Option Find)
Departments on 1st floor of Building C
..........................................................
Enter the ssn for the employee
124-54-9999
55N,:124-54-9999
Firstname , Shannon
Lastname : Thomas
Middle Initial : L
City : Monroe
State ,:MI
Age ,:23
Depart 10,:5454
Depart Name : Human Resources
3uilding Letter: 8
3uilding floor : 3
Phone Number: 124-999-99e
Enter your selection (6 for menu -999 to exit): Departments on 1st floor of Building C
Enter the ssi for the employee
1234567
The enployee with the ssn of 1234567 does not exist
Enter your selection (8 for menu -999 to exit):
Option 6
Average age for employees who live in MI
36
Enter your selection (6 for menu -999 to exit):
-999
Press any key to continue ...
In C + + , This program is going to make use of

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 Programming Questions!