#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
constint NUM_EMPLOYEES = 7; // Constant int for employee amount.
constint STRING_SIZE = 8; // Constant int for string size.
int hours[NUM_EMPLOYEES]; // Int hours, because it's an integer.
int payRate[NUM_EMPLOYEES]; // Int payRate, because it's an integer.
float wages[NUM_EMPLOYEES]; // Float wages, because it can be a decimal.
cout << "Enter the requested information for each employee. " << endl;
cout << endl;
// Array with the 7 employee identification numbers.
char empId[NUM_EMPLOYEES][STRING_SIZE] =
{ "5658845", "4520125", "7895122", "8777541",
"8451277", "1302850", "7580489" };
for ( int count = 0; count < NUM_EMPLOYEES; count++ )
{
cout << "Employee #" << empId[count] << endl;
cout << '\t' << "Hours worked: " << " ";
cin >> hours[count];
while( hours[count] < 0 ) // Hours worked must be at least 0.
{
// Error message.
cout << "Hours worked must be 0 or more. Please re-enter: " << "";
cin >> hours[count];
}
cout << '\t' << "Pay rate: $" << " ";
cin >> payRate[count];
while( payRate[count] < 6 ) // Pay rate must be at least $6.
{
// Error message.
cout << "Pay rate must be $6.00 or more. Please re-enter: $" << "";
cin >> payRate[count];
}
wages[count] = hours[count] * payRate[count]; // Calculates employees wages.
cout << "----------------------------" << endl;
cout << "Employee" << '\t' << "Wages" << endl;
cout << "----------------------------" << endl;
cout << "Employee #" << empId[count] << " " << "$ " << wages[count] << endl;
}
return 0;
}
There is my code. It displays the employees # and wage after each employee, but I only want it to do it once after all 7 employee's info is entered. I move the chart outside the loop and I get an error for empId[count].