(10 points) - This program will create a simple employee paycheck
calculator using parallel arrays and an array of C-style strings. Use the
following menu for the program:
Welcome to the Employee Paycheck Calculator
===========================================
1. Add employee record(s) to the database
2. Print all employee records
3. Print the paycheck for one employee
4. Print paychecks for all employees
0. Exit
===========================================
Enter selection:
Each employee will have three pieces of data: a name, a pay rate and hours
worked this pay period. These will be stored in the following parallel arrays:
- An array of C-style strings to store the employee names.
- A double array to store the pay rate for each employee.
- A double array to store the hours worked in this pay period for each
employee.
Each index in the array will correspond to a particular employee, e.g., index
0 of each array will correspond to the first employee. The arrays must all be
declared in main()'s scope and passed to the functions. Use a partially filled
array for each array, although the current size variable can be shared among
all arrays since each array will contain the same number of employees.
To support each option, main() will make function calls. Before calling the
functions for Options 2, 3, and 4, validate that the current number of
employees is greater than 0. If it is not, tell the user to select Option 1
first. Do NOT reset the current number of employees after selecting Options
2, 3, or 4.
For Option 3, you will ask the user to select an index number corresponding
to the employee whose paycheck is to be printed out. You MUST validate that
the user has selected a valid index number (0 to current size - 1). If the
user has selected an invalid index number, print an error message and break
out of the select statement (which will trigger the next iteration of the
menu loop). When the user has selected a valid index, rather than passing the
arrays to the printEmployeePaycheck() function, you will be passing the
values at the selected index, e.g., name[0] instead of the whole name array
if the user selected index 0.
You will have at least the following four functions (you may add more
functions if you wish) to support the options:
- addEmployees - This is a void function. It takes four parameters: the array
of C-style strings for the name, the array of doubles for the pay rate, the
array of doubles for the hours worked and a by-reference parameter for the
current number of employees. It will prompt the user for how many employees
they wish to add and verify that the requested size is greater than 0 and
that the arrays can hold the requested size (e.g., that the requested size is
less than or equal to the maximum size of the arrays). It will then loop,
prompting the user to enter each employee's name, pay rate and hours worked
for the pay period.
- displayAllEmployees - This is a void function. It takes four parameters:
the array of C-style strings for the name, the array of doubles for the pay
rate, the array of doubles for the hours worked and a by-value parameter for
the current number of employees. It will print all of the employees, using
formated output, in a fashion similiar to the following:
Index Name Rate Hours
0 John Smith 10.50 40
1 Jane Doe 10.50 45.5
2 John Doe 8.90 30.5
- printEmployeePaycheck - This is a void function. It takes three parameters:
the C-style string for the employee name, a double for the employee's pay rate,
and a double for the hours the employee worked in the current pay period. This
prints out the paycheck for a single employee. It should be printed using
formated output in a fashion similiar to the following:
Employee: John Doe Rate: 8.90 Hours: 30.5 Weekly Pay: $271.45
- printAllPaychecks - This is a void function. It takes four parameters:
the array of C-style strings for the name, the array of doubles for the pay
rate, the array of doubles for the hours worked and a by-value parameter for
the current number of employees. It will loop through all the employees,
calling the printEmployeePaycheck() function for each individual employee.
The output should resemble:
Employee: John Smith Rate: 10.50 Hours: 40 Weekly Pay: $420.00
Employee: Jane Doe Rate: 10.50 Hours: 45.5 Weekly Pay: $477.75
Employee: John Doe Rate: 8.90 Hours: 30.5 Weekly Pay: $271.45