Quiz 4 Problem 30 points Write a program which uses the foll

Quiz 4
Problem: 30 points
Write a program which uses the following arrays:
1. empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7.
2. Hours: an array of seven integers to hold the number of hours worked by each employee.
3. payRate: an array of seven doubles to hold each employee’s hourly pay rate.
4. Wages: an array of seven doubles to hold each employee’s gross salary.
5. The program should display each employee number and ask the user to enter that employee’s hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate) and store them in the wages array. After the data has been entered for all the employees, the program should display each employee’s identification number and gross wages.
6. Input validation: pay rate must be greater than or equal to $5 but less than or equal to $15
7. Input validation: hours worked must be greater than 0 but less than or equal to 40
8. Input validation: no “garbage” or blanks allowed for pay rate or hours worked
IMPORTANT NOTE: you must use the enclosed .cpp file to develop your program. Your task it to write the main() function as well as the definitions for the function prototypes.
RESTRICTIONS
1. You may not use global variables
2. You may not use GOTO statements
3. You must use the “Data.txt” file provided; failure to use this file and not adhere to the requirements will severely affect your grade
4. You may NOT use code from the Web Grading Points Criteria
5
The function validateHoursWorked correctly validates the hours worked 10 The function validatePayRate correctly validates the pay rate
20
The function getEmployeeInfo correctly displays employee IDs stored in 1st array; correctly asks for input and stores hours worked and pay rate information in the 2nd and 3rd arrays; correctly calculate gross pay, which it stores in the 4th array. 5 The function displayWages correctly displays each employee ID and gross pay
If your program crashes for whatever reason, you lose 90% of the points If your program won’t compile, you lose 90% of the points

Solution

#include #include #include #include using namespace std; int main() { const int empId = 7; int workers[empId] = {5658846, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489}; int hours[empId]; double payRate[empId]; \\ cout << \"Please enter the hours worked by \" << empId << \" employees and their\ \" << \"hourly pay rates.\ \"; for (int index = 0; index < empId; index++) { cout << \"Please enter the hours worked by employee number \" << (index+1) << \" (ID = \" << workers[index] << \") : \"; cin >> hours[index]; cout << \"Please enter the pay rate for employee number \"<< (index+1) << \" (ID = \" << workers[index] << \") : \"; cin >> payRate[index]; do { cout << \"Please enter the hours worked by employee number \" << (index+1) << \" (ID = \" << workers[index] << \") : \"; cin >> hours[index]; if(hours[index] < 0) { cout << \"Enter in a positive number\" << endl; } } while(hours[index] < 0); do { cout << \"Please enter the pay rate for employee number \"<< (index+1) << \" (ID = \" << workers[index] << \") : \"; cin >> payRate[index]; if(payRate[index] < 6) { cout << \"The pay rate must be >= 6\" << endl; } } while(hours[index] < 6); cout << \"This is the gross pay for each employee:\ \"; cout << fixed << showpoint << setprecision(2); for (int index = 0; index < empId; index++) { double grossPay = hours[index] * payRate[index]; cout << \"Employee #\" << (index + 1); cout << \": earned $\" << grossPay << endl << endl; { return 0; }
Quiz 4 Problem: 30 points Write a program which uses the following arrays: 1. empID: An array of 7 integers to hold employee identification numbers. The array s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site