Originally posted by Fender2112
I tried both of these suggestions but neither worked.
Here's the code I'm using with CodeWarrior:
//***************************************************************************************
//* This program uses a two dimensional arrary to store the hours worked for five days *
//* for five employees. The user enters the hours worked each day for each employee. *
//* A daily average is calculated for the five day period for each employee. *
//***************************************************************************************
int main ()
{
float hoursWorked [5] [5]; // Two dimensional array with five elements in each dimension
float totHours, dayAvg;
for (int emp = 1; emp <= 5; emp ++) // This loop sets first index of the array
{
//*** I need to clear the screen here ***
system("cls");
system ("clear");
totHours = 0; // reset totals for each employee
dayAvg = 0;
cout.precision(2); // Use this and
cout.setf(ios::fixed | ios::showpoint); // this to set decimal precision
cout << "Enter the hours workd each day for employee: " << emp << endl;
for (int day = 1; day <= 5; day ++) // This loop sets the second index of the array
{
cout << "How many hours did this employee work on day " << day << ": ";
cin >> hoursWorked [emp] [day];
totHours = totHours + hoursWorked [emp] [day];
}
// Calculate the daily average for this employee
dayAvg = totHours / 5;
cout << "This employee has a daily average of " << dayAvg << " hours.";
cout << endl << endl;
//*** I need to pause here ***
system("pause");
system("echo -n Press ENTER to continue. ; echo $<"); // pause for input
}
return 0;
}
//*** End Program ***