Write a program for Nations Bank in Hyatesville that will fi
Write a program for Nation\'s Bank in Hyatesville that will find the total number of days its employees were out sick for the specified past few years. The program will prompt the user to specify the number of past years to consider. It will also prompt the user for the number of tellers worked in the bank for the past specified years. For each worker the program should ask for the number of days out sick for each of the last specified years. The output should provide the number of tellers and the total number of dap missed by all the tellers over the last specified years. See the sample output below. How many past years do you want to consider ? 3 How many tellers worked at Nation\'s Bank during each of the last 3 years ? 2 How many days was teller 1 out sick during year 1 ? 5 How many days was teller 1 out sick during year 2 ? 8 How many days was teller 1 out sick during year 3 ? 2 How many days was teller 2 out sick during year 1 ? 1 How many days was teller 2 ou
Solution
The c++ program which calculates the total number of days which all the employees were sick is shown below.
#include <iostream>
using namespace std;
int main()
{
int years = 0,employees = 0, i = 0, j = 0,temp = 0,total_days = 0;
cout<<\"How many past years do you want to consider?\";
cin>>years;
cout<<\"How many tellers worked at Nation\'s Bank during each of the last \"<<years<<\" years?\";
cin>>employees;
for(i=1;i<=employees;i++){
for(j=1;j<=years;j++){
cout<<\"How many days was teller \"<<i<<\" out sick during year \"<<j<<\" ?\";
cin>>temp;
total_days+=temp;
}
}
cout<<\"The \"<<employees<<\" tellers were out sick for a total of \"<<total_days<<\" days during the last \"<<years<<\"years\";
return 0;
}
