Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Write a program that does the following: Reads 5 employee identification numbers from a file. Asks the user to enter the number of

C++ Programming

Write a program that does the following: Reads 5 employee identification numbers from a file. Asks the user to enter the number of hours worked during the week and pay rate of each employee. Calculates the gross salary of each employee. Writes to a file the employee identification number and gross salary of each employee. The program MUST use the following parallel arrays: an array to store 5 employee identification numbers. This array must be filled with the employee identification numbers stored in the file employee_ids.txt. (Note: Download the file from the link at the top by right clicking.) an array to store the number of hours worked during the week by each employee. This array will be filled with input provided by the user. an array to store the hourly pay rate of each employee. This array will be filled with input provided by the user. an array to store the gross salary of each employee. The gross salary of an employee is computed by multiplying the employee's hourly pay rate times the number of hours worked. The program MUST have the following functions (You are allowed to use additional functions): A function that opens the file employee_ids.txt containing the employee identification numbers. This function only opens the file for input. It doesn't read the contents of the file. The user must be asked to enter the location and name of the file. If the file specified can't be found, a loop must be used to continue to prompt the user for a valid file location and name. A function that opens the output file for writing. This function only opens the file for output. It doesn't write the results to the file. The user must be asked to enter the location and name of the file. If the file specified is not valid, a loop must be used to continue to prompt the user for a valid file location and name. A function which reads the employee identification numbers from the input file and stores them in the appropriate array. A function that asks the user to enter the number of hours worked during the week and pay rate of each employee, and stores the information in the corresponding arrays. The employee identification number of the employee MUST be displayed before asking the user for the employee's information. The number of hours worked must be zero or greater, and the pay rate must be $7.50 or greater. If the input provided is not valid, a loop must be used to continue to prompt the user for valid data. A function that calculates the gross salary of each employee and stores it in the corresponding array. A function which writes to the output file the employee indentification number and gross salary of each employee. The output should be formatted nicely. Here is sample program run: Enter the hours worked and pay rate for the employee with id A12345: Hours: 20 [Enter] Pay rate: $10.50 [Enter] Enter the hours worked and pay rate for the employee with id B55874: Hours: 25 [Enter] Pay rate: $15.00 [Enter] Enter the hours worked and pay rate for the employee with id C69851: Hours: 30.75 [Enter] Pay rate: $20.25 [Enter] Enter the hours worked and pay rate for the employee with id D12458: Hours: 35 [Enter] Pay rate: $22.00 [Enter] Enter the hours worked and pay rate for the employee with id E52242: Hours: 40 [Enter] Pay rate: $25.50 [Enter] Output written to file: Employee ID Gross Salary A12345 $210.00 B55874 $375.00 C69851 $622.69 D12458 $770.00 E52242 $1020.00 Note: The above program run is just an example. The ids stored in the input file will be different! Other Requirements: GLOBAL VARIABLES THAT ARE NOT CONSTANTS ARE PROHIBITED! 50 POINTS WILL BE DEDUCTED FOR EACH NON-CONSTANT GLOBAL VARIABLE! Functions that will only read the contents of an array should NOT be allowed to modify its contents! Loops must be used to process the arrays and files! The output must be aligned and nicely formatted!

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 Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

=+ Who do you think is right? Why?

Answered: 1 week ago