Solved 1 Answer
See More Answers for FREE
Enhance your learning with StudyX
Receive support from our dedicated community users and experts
See up to 20 answers per week for free
Experience reliable customer service
#include<iostream> #include<iomanip> using namespace std; void menu(); double calculateCharges(double,double); double calculateCharges(int, double, double,double); int main() {    int number_of_days=1,user_choice;    double dailyRate=50,hospital_medication_charges=0,service_cahrges=0,total_charges;    cout<<fixed<<setprecision(2);    do    {        menu();        cin>>user_choice;        if(user_choice==1)        {            while(true)            {                cout<<"Please enter a non-negative value for the number of days spent in the hospital (default: 1 day):n";                cin>>number_of_days;                if(number_of_days>0)                    break;            }            while(true)            {                cout<<"Please enter a non-negative value for the daily rate (default: &50):n";                cin>>dailyRate;                if(dailyRate>0)                {                    if(dailyRate<50)                    {                        dailyRate=50;                    }                    break;                }            }            while(true)            {                cout<<"Please enter a non-negative value for charges for hospital medication cahrges (default: &0):n";                cin>>hospital_medication_charges;                if(hospital_medication_charges>0)                    break;            }            while(true)            {                cout<<"Please enter a non-negative value for charges for hospital services (lab tests,etc default: &0):n";                cin>>service_cahrges;                if(service_cahrges>0)                    break;            }            total_charges=calculateCharges(number_of_days,dailyRate,hospital_medication_charges,service_cahrges);            cout<<"The total In-Patient charge is, $"<<total_charges<<endl;        }        else if(user_choice==2)        {            while(true)            {                cout<<"Please enter a non-negative value for charges for hospital medication cahrges (default: &0):n";                cin>>hospital_medication_charges;                if(hospital_medication_charges>0)                    break;            }            while(true)            {                cout<<"Please enter a non-negative value for charges for hospital services (lab tests,etc default: &0): ";                cin>>service_cahrges;                if(service_cahrges>0)                    break;            }            total_charges=calculateCharges(hospital_medication_charges,service_cahrges);            cout<<"The total Out-Patient charge is, $"<<total_charges<<endl;        }    }while(user_choice!=3);    cout<<"Quit the program."<<endl; } void menu() {    cout<<"**** Hospital Charge Calculator ****"<<endl;    cout<<"1. Calculate the In-Patient Charge"<<endl;    cout<<"2. Calculate the Out-Patient Charge"<<endl;    cout<<"3. Quit"<<endl;    cout<<"Enter your choice (1 - 3): "; } double calculateCharges(double mediCharges,double serviceCharges) {    return mediCharges+serviceCharges; } double calculateCharges(int days, double dailyRate, double mediCharges,double serviceCharges) {    return (days*dailyRate+mediCharges+serviceCharges); }   Please upvote if you like the answer  ...