after i was able to get my other program to run with everyone's input I decided to try a different one to get a better understanding of function programming. I current objective is to write a program that computes and displays the charges for a patient’s hospital stay.
The program design is:
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:
• The number of days spent in the hospital
• The daily rate
• Hospital medication charges
• Charges for hospital services (lab tests, etc.)
The program should ask for the following data if the patient was an out-patient:
• Charges for hospital services (lab tests, etc.)
• Hospital 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 information. Both functions should return the total charges. Input Validation: Do not accept negative numbers for any data.
The issues I am having when I attempt to complie state:
too few arguments to function `double getInPatient(int, double, double, double)'
too few arguments to function `double getOutPatient(double, double)'
it also states varibles that are declared as undeclared.
ambiguates old declaration `double getInPatient(int, double, double, double)'
ambiguates old declaration `double getOutPatient(double, double)'
I do believe if I can get past the too few arguments to function issues the rest might be taken of. Thank you in advance to all who come to my aid.
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
// *****************************************************************************
// Program: Overloaded Hospital
// Purpose: program that computes and displays the charges for a patient's
// hospital stay. 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: The number of days spent in the hospital, The
// daily rate, Hospital medication charges, and Charges for hospital
// services (lab tests, etc.) ask for the following data if the patient
// was an out-patient: Charges for hospital services (lab tests, etc.)
// and Hospital medication charges. Input Validation: Do not accept
// negative numbers for any data.
// *****************************************************************************
# include <iostream>
using namespace std;
double getInPatient(int numberofDays, double dailyRate, double hospitalMedicationCharge, double chargesForHospitalServices);
double getOutPatient(double hospitalMedicationCharge, double chargesForHospitalServices);
int main()
{
char patientStatus;
cout << "Is the patient an In-patient or Out-patient: ";
cin >> patientStatus;
while (patientStatus !='I' || patientStatus !='i'
|| (patientStatus != 'O' || patientStatus != 'o'))
{
cout << "ERROR! Please enter one of the following (I,i O, o): ";
cin >> patientStatus;
}
if (patientStatus == 'I' || patientStatus == 'i')
{
getInPatient();
}
else
{
getOutPatient();
}
cout << "Patient Status is: " << patientStatus << endl;
if (patientStatus == 'I' || patientStatus == 'i')
{
cout << "Patient was in for " << numberofDays << " days.\n";
cout << "Patient has accumulated " << dailyRate << " for the stay.\n";
cout << "Patient has accumulated " << hospitalMedicationCharge
<< " in medication charges for the stay.\n";
cout << "Patient has accumulated " << chargesForHospitalServices
<< " in charges for hospital related services for the stay.\n";
}
else
{
cout << "Patient has accumulated " << hospitalMedicationCharge
<< " in medication charges for the stay.\n";
cout << "Patient has accumulated " << chargesForHospitalServices
<< " in charges for hospital related services for the stay.\n";
}
system("pause");
return 0;
}
// Get the in-patient's data
void getInPatient(int numberofDays, double dailyRate,
double hospitalMedicationCharge,
double chargesForHospitalServices)
{
cout << "Please enter the number of days spent in the hospital: ";
cin >> numberofDays;
while (numberofDays < 0)
{
cout << "ERROR! In-patients can not have a negative numbers of days"
<< ". Try again: ";
cin >> numberofDays;
}
cout <<"\nPlease enter the daily rate of the in-patient: ";
cin >> dailyRate;
while (dailyRate < 0)
{
cout << "ERROR! In-patients can not have a negative daily rate"
<< ". Try again: ";
cin >> dailyRate;
}
cout << "\nPlease enter the Hospital medication charges of the"
<<" in-patient: ";
cin >> hospitalMedicationCharge;
while (hospitalMedicationCharge < 0)
{
cout << "ERROR! Hospital medication charges can not have a negative"
<< " value. Try again: ";
cin >> hospitalMedicationCharge;
}
cout <<"\nPlease enter the Charges for hospital services "
<<"(lab tests, etc.) of the in-patient: ";
cin >> chargesForHospitalServices;
while (chargesForHospitalServices < 0)
{
cout << "ERROR! In-patients can not have a negative charges for"
<< " hospital services. Try again: ";
cin >> chargesForHospitalServices;
}
}
// Get the out-patient data
void getOutPatient(double hospitalMedicationCharge,
double chargesForHospitalServices)
{
cout << "\nPlease enter the Hospital medication charges of the"
<<" in-patient: ";
cin >> hospitalMedicationCharge;
while (hospitalMedicationCharge < 0)
{
cout << "ERROR! Hospital medication charges can not have a negative"
<< " value. Try again: ";
cin >> hospitalMedicationCharge;
}
cout <<"\nPlease enter the Charges for hospital services "
<<"(lab tests, etc.) of the in-patient: ";
cin >> chargesForHospitalServices;
while (chargesForHospitalServices < 0)
{
cout << "ERROR! In-patients can not have a negative charges for"
<< " hospital services. Try again: ";
cin >> chargesForHospitalServices;
}
}
|