You are required to write a C++ program to assist Dr Plaatje with the running of her surgery. She needs to know: 1) how many patients she has seen in the month. 2) the five (5) day in which she made most the money, (five highest earning days). If there are more than one (1) days in which she made the same amount, just indicate that it was duplicated on a particular day. Only note or record the last duplicate. 3) how much money she has collected in the month. Also: (a) Your program must run until the user stops it when the surgery closes at the end of the day, when the report has to be generated. (b) Assume a month has 31 days at most. (c) Your program must ensure that input day is within the range [1..31]. It must not accept days outside the range.
#include <iostream>
using namespace std;
int main()
{
int day[31];
int number_of_patients[31];
int money[31];
int i=0;
while(true){
cout<<"\nEnter index of the day: ";
cin>>day[i];
cout<<"\nEnter number of patient on day "<<day[i]<<": ";
cin>>number_of_patients[i];
cout<<"\nEnter money collected on day "<<day[i]<<": ";
cin>>money[i];
int c;
cout<<"\nContinue? 1.Yes 2. No: ";
cin>>c;
if (c==2)
break;
i++;
}
int sum=0;
for(int i=0;i<31;i++){
sum=sum+number_of_patients[i];
}
cout<<"\nNumber of patient in a month = "<<sum;
int sum2=0;
for(int i=0;i<31;i++){
sum2=sum2+money[i];
}
cout<<"\nAmount of money in a month = "<<sum2;
return 0;
}
Comments
Leave a comment