I have to write a program that must compute and display the charges for a patients hospital stay. first the program should ask if the patient was admitted as an in patient or an out patient. If the patient was as an in-patient the following data should be entered:
the number of days spent in the hospital
the daily rate
charges for hospital services (lab tests, etc.)
hospital medication charges
If the patient was an out patient the following data should be entered:
charges for hospital services (lab tests, etc.)
hosppital medication charges
the program should use two overloaded functions to calculate the total charges. one of the functions should accept arguments for the in patient data, while the other function accepts arguments for out patient data. Both functions should return the total charges.
Input validation: do not accept negative numbers for any information. Im having trouble getting my data to come out right.
And this is what I have to far: // This program computes and displays patient hospital charges.// It uses overloaded functions.#include <iostream>#include <iomanip>using namespace std;// Function prototypesdouble patientCharges(int, double, double, double); // In-patientdouble patientCharges(double, double); // Out-patientint main(){ char patientType; // I=in-patient, O=out-patient int days; // Number of days of hospital stay double roomRate, // Daily room rate medication, // Total medication charges services, // Total for tests and other services totalCharges; // Total of all charges // Input and validate patient type cout << "This program will compute patient hospital charges.\n"; cout << "Enter I for in-patient or O for out-patient: "; cin >> patientType; //add code here // Input and validate data relevant to in-patients //add code here // Input and validate data relevant to all patients //add code here // Call correct patientCharges function to return total charges //add code here // Display the billing statment cout << fixed << showpoint << setprecision(2) << endl << endl; cout << "******************************\n"; if (patientType == 'I') cout << "Room charges $" << setw(8) << days*roomRate << endl; if (services > 0.0) cout << "Lab & Services $" << setw(8) << services << endl; if (medication > 0.0) cout << "Medication $" << setw(8) << medication << endl; cout << "Total charges $" << setw(8) << totalCharges << endl; cout << "******************************\n"; return 0;}// End of main function/************************************************************* * patientCharge * * This function is called by main to calculate and return * * total patient charges for in-patients * *************************************************************/double patientCharges(int days, double rate, double med, double serv){ //add code here}// end overload function patientCharges/************************************************************* * patientCharge * * This function is called by main to calculate and return * * total patient charges for out-patients * *************************************************************/double patientCharges(double med, double serv){ //add code here}// end overload function patientCharges
can anyone help?