int main()
{
char selection; // Menu selection
int HospitalStay; // Days in the Hospital
double rate; // Daily rate
double MedicationCharges; // Hospital medication charges
double HospitalSvces; // labs tests
// Set the numeric output formatting.
cout << fixed << showpoint << setprecision(2);
// Display the menu and get a selection.
cout << "patient status \n";
cout << "(I)in-patient, or \n";
cout << "(O)out-patient?\n";
getChoice(selection);
// Process the menu selection.
switch (selection)
{
// in-patient
case 'I':
case 'i': cout << "How many days spent in the hospital?";
cin >> HospitalStay;
cout << "The daily rate";
cin >> rate;
cout << "Hospital medication charges";
cin >> MedicationCharges;
cout << "Charges for hospital services";
cin >> HospitalSvces;
cout << calcTotal( HospitalStay,rate) << endl;
cout << "Total charges is $";
cout << calcTotal(MedicationCharges,HospitalSvces) << endl;
cout << "Total charge is $";
break;
void getChoice(char &letter)
{
// Get the user's selection.
cout << "Enter your choice ( I or O): ";
cin >> letter;
// Validate the selection.
while (letter != 'I' && letter != 'i' && letter != 'O' && letter != 'o')
{
cout << "Please enter I or O: ";
cin >> letter;
}
Your problem is like usually with linker errors: Your prototype double calcTotal(int, double); differs from your implementation double calcTotal(double rate, int HospitalStay)
Using unsignedint will not prevent someone calling the function with negative numbers. If you pass a negative number where an unsigned int is expected then it's complement will be used instead giving you an entirely unexpected number.