In this code it does not run my first function getPatientType. This code skips directly to the, "what are the medical charges and then asks for the service charges and returns 0 no matter what I enter. I am looking for some assistance in getting this code up and running correctly.
#include <iostream>
#include <iomanip>
using namespace std;
int numdays;
float dailyRate;
double medChrg;
double totalChrg;
char doAgain;
char patientType;
int daysHospital;
double serviceChrg;
int main()
{
I'm not sure if this is the correct way to call this function, and why it does not run.
char getPatientType(char);
if (patientType == 'y' || patientType == 'Y')
{
cout << "How many days was the patient in the hospital? ";
cin >> daysHospital;
while (daysHospital < 0) {
cout << "Enter a valid number of days: ";
cin >> daysHospital;
}
cout << "What is the daily rate? : ";
cin >> dailyRate;
while (dailyRate < 0)
{
cout << "Enter a valid daily Rate. : ";
cin >> dailyRate;
}
}
cout << "What are the medical charges?: ";
cin >> medChrg;
while (medChrg < 0) {
cout << "Enter a valid medical charge : ";
cin >> medChrg;
}
cout << "What are the services charges?: ";
cin >> serviceChrg;
while (medChrg < 0) {
cout << "Enter a valid medical charge : ";
cin >> medChrg;
}
double calcBillFor(int, float, double, double);
double calcBillFor(double, double);
cout << "The charges for the patient will be " << totalChrg;
system("pause");
}
char getPatientType(char) {
cout << "What is the type of Patient, type I for Impatient, and O for
Outpatient?: ";
cin >> patientType;
if (patientType != 'I' || patientType != 'i' || patientType != 'o' ||
patientType != 'O')
{
cout << "Enter a valid patient type: ";
cin >> patientType;
}
return patientType;
}
I am also supposed to utilize the ability of C ++ being able to overload, so these two functions are called with the same name but different parameters.
double calcBillFor(int, float, double, double) {
totalChrg = (dailyRate * daysHospital) + medChrg + serviceChrg;
return totalChrg;
}
double calcBillFor(double, double) {
totalChrg = (medChrg + serviceChrg);
return totalChrg;
}
The system does not show I have any errors so I am confused as to why the entire code does not run correctly. If there is anything I am missing or logical errors please help.