Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would you create this program in c++ language with no global variables? The Input file: Class members contributed employee data (name, integer ID, number

image text in transcribed

How would you create this program in c++ language with no global variables?

The Input file: Class members contributed employee data (name, integer ID, number of years of service, salary) and it in a file named staff.txt. A 4th data member, the employee ID, is to be added to the employee class definition. A company will use an array of employee objects to store employee data; the company plans to grow, so the array size will be larger than the actual number of people they employ. The declaration can be:

employee personnel[50];

The default constructor will initialize the 50 objects in the array. An input file has employee data which is read into variables such as strName, id, years, and pay, then an array object calls the class setData function with the variables as parameters:

personnel[index].setData(strName, id, years, pay);

The input function determines how many actual employees there are.

The output function has each array object call its print function.

This lab leads into Program 6, which will add processing to the array of employee objects.

The staff.txt is:

Alexa Reed 214192 6 2600000000.00 Fru Tawah 24278916 5 150000.00 Jack Wilson 8675309 40 1000003.00 Julie Gold 5697623 18 352080.76 Zainab Almutawa 1015948555 4 180000.00 Free Bandz Lotty 8 6 180565.00 McDane McFarlane 4134560 7 150000.00 Olasumbo Olagoke 134 7 120000.00 Daniel Francois, III 2056 3 115000.00 Jane Doe 217110 8 42839.92 
This project extends the labs on the class employee, done on April 11 and 13. Use your header file employee h which has four data members in the employee class (including empID), and has the setData function with parameters for each of the four data members of the class. For the lab, you developed a main program which declared an array of employee objects, called an input function to read employee data from an input file to put values in some of the array objects, and used a for loop to print the data in the objects that received input data. You will use these features, and extend the actions to be performed on the employee objects. Declare an array named personnel, consisting of employee objects. Call the input function to read in the array data from the input file staff.txt, as before. Then add functions as needed for a user-driven program to allow the user to Add an employee the user specifies the employee data by keyboard input Print all employees' data Print a particular employee's data-the user specifies the employee ID Give every employee a cost-of-living-allowance, by increasing the salary by 2% Have a Menu function which presents these choices to the user, and returns the user's selection When the user's choice has been done, show the menu again and repeat: have the user end the program by selecting a Quit choice from the menu. (One example of a menu function is in the Candy Machine example at the end of the chapter on classes.)

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

More Books

Students also viewed these Databases questions