Hello all,
My assignment is as follows: Write a program that prompts the user for the number of tellers at Nation’s Bank in Hyatesville that worked each of the last three years. For each worker the program should ask for the number of days out sick for each of the last three years. The output should provide the number of tellers and the total number of days missed by all the tellers over the last three years.
I've got the body right (I think), so it does ask how many tellers and covers a three year period of time, but for the life of me I cannot figure out how to get totals from each tellers days out to one big total outside the loop. I'm sure it's simple math but I would really appreciate any help with the syntax (hope that was the right word). The last total is where I am stumped. Thanks in advance.
// This program finds the number of days a teller was
// out of work sick over a three year period.
// Christine
#include <iostream>
using namespace std;
int main()
{
int numTellers;
float sickDays, totalsick, total = 0;
int teller, year = 0; // these are the counters for the loops
cout << "This program finds the number of days a teller \n"
"was out of work sick over a three year period\n" << endl;
cout << "How many tellers worked at Nation's Bank during each of the \n"
"last three years?\n\n";
cin >> numTellers;
for (teller = 1; teller <= numTellers; teller++)
{
totalsick = 0;
for (year = 1; year <= 3; year++)
{
cout << "\nPlease enter the number of days teller " << teller << " was out "
"sick in year " << year << "." << endl;
cin >> sickDays;
totalsick = totalsick + sickDays;
}
}
cout << "\nThe " << numTellers << " tellers were out of work sick for a total \n"
"of " << total << " days during the last three years." << endl << endl;
return 0;
}