Answer to Question #261202 in C++ for DANIEL

Question #261202

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.


1
Expert's answer
2021-11-05T00:33:34-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS