-
November 13th, 2010, 05:50 PM
#1
[RESOLVED] C++ Payroll Question
The program asks the following...
Use the following test data:
5658845 -1,6 5,6 (these value will demonstrate input validation)
4520125 7 7
7895122 8 8
8777541 9 9
8451277 10 10
1302850 11 11
7580489 12 12
Hint: To facilitate testing, declare a const int size that will be used in the array declarations and the for loops. Initialize size to 2 while you are testing (to save time entering values). When your program works, initialize size to 7 for your final execution run.
Output should appear as shown below:
Enter the requested information for each employee.
Employee #5658845
Hours worked: -1
Hours worked must be 0 or more. Please re-enter: 6
Pay rate: $5
Pay rate must be 6.00 or more. Please re-enter: $6
Employee #4520125
Hours worked: 7
Pay rate: $7
Employee #7895122
Hours worked: 8
Pay rate: $8
Employee #8777541
Hours worked: 9
Pay rate: $9
Employee #8451277
Hours worked: 10
Pay rate: $10
Employee #1302850
Hours worked: 11
Pay rate: $11
Employee #7580489
Hours worked: 12
Pay rate: $12
----------------------------
Employee Wages
----------------------------
Employee #5658845 $ 36.00
Employee #4520125 $ 49.00
Employee #7895122 $ 64.00
Employee #8777541 $ 81.00
Employee #8451277 $ 100.00
Employee #1302850 $ 121.00
Employee #7580489 $ 144.00
Press any key to continue . . .
I currently have...
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int NUM_EMPLOYEES = 7;
const int STRING_SIZE = 8;
int hours[NUM_EMPLOYEES];
int payRate[NUM_EMPLOYEES];
float wages[NUM_EMPLOYEES];
cout << "Enter the requested information for each employee. " << endl;
for (int count = 0; count < NUM_EMPLOYEES; count++)
{
// Array with the eployee identification numbers.
char empId[NUM_EMPLOYEES][STRING_SIZE] =
{ "5658845", "4520125", "7895122", "8777541",
"8451277", "1302850", "7580489" };
cout << "Hours worked: " << endl;
cin >> hours[count];
while( hours[count] <= 0 )
{
cout << "Hours worked must be 0 or more. Please re-enter: " << " ";
cin >> hours[count];
}
cout << "Pay rate: " << endl;
cin >> payRate[count];
while( payRate[count] <= 0 )
{
cout << "Pay rate must be 6.00 or more. Please re-enter: " << " ";
cin >> payRate[count];
}
{
wages[count] = hours[count] * payRate[count];
cout << "----------------------------" << endl;
cout << "Employee" << '\t' << "Wages" << endl;
cout << "----------------------------" << endl;
cout << "Employee #" << empId[count] << " " << "$ " << wages[count] << endl;
}
}
return 0;
}
Need help getting it to display empId # each time and it displays the chart each time I enter hours and payRate, but I want it to do that at the end. I've gotten pretty far, but now I'm stuck. Any help???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|