Cant get the catch out of this program, maybe someone can lend me a hand.
Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered:
-Number of Days spent in a Hospital
-The daily rate
-Charges for the hospital services(lab test, etc)
-Hospital medication charges
If the the patient was an out-patient the following data should be entered:
-Charges for Hospital services(lab test, etc)
-Hospital medication charges
The program should use two 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.
I dont know why but the result always gives me 0???
This is what I have, thank you for your time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include<iostream>
using namespace std;
double in_patient(int Numdays, double dailyRate, double Charge_hospServices, double HospMed_Charge);
double out_patient(double Outcharge_Service, double OuthospMed_Charge);
int main()
{
double dailyRate, Charge_hospServices,HospMed_Charge,Outcharge_Service,OuthospMed_Charge;
int Numdays;
char response;
cout<<"Enter (Y) if you are an in patient or (N0) if you are an out patient:";
cin>>response;
if (response == 'Y')
{
cout<<"Number of days spent in a hospital:";
cin>>Numdays;
cout<<"The daily rate:";
cin>>dailyRate;
cout<<"Charges for the hospital services:";
cin>>Charge_hospServices;
cout<<"Hospital Medication Charges:";
cin>>HospMed_Charge;
}
else if (response == 'N')
{
cout<<"Charges for the hospital service:";
cin>>Outcharge_Service;
cout<<"Hospital medication Charges:";
cin>>OuthospMed_Charge;
}
if (Numdays<0 || dailyRate<0 || Charge_hospServices<0 || HospMed_Charge<0 || Outcharge_Service<0 || OuthospMed_Charge<0){
cout<<"Please try again:";
}
}
double in_patient(int Numdays, double dailyRate, double Charge_hospServices, double HospMed_Charge)
{
int totalCharge;
totalCharge = (Numdays * dailyRate) + Charge_hospServices + HospMed_Charge;
return totalCharge;
}
double out_patient(double Outcharge_Service, double OuthospMed_Charge)
{
int totalCharge;
totalCharge = (Outcharge_Service+OuthospMed_Charge);
return totalCharge;
}
|