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
|
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <stdlib.h>
using namespace std;
// Global Constants
const int in_patient = 1,
out_patient = 2;
// Global Variables
int num_days;
double daily_rate,
in_med_charge,
in_serv_charge,
out_serv_charge,
out_med_charge,
in_tot_charge,
out_tot_charge;
// Function Prototypes
double getCharges (int, double, double, double);
double getCharges (double, double);
int main()
{
int choice;
cout << "========================================" << endl;
cout << " HOSPITAL CHARGES " << endl;
cout << "========================================" << endl;
cout << endl << endl;
cout << "Welcome! Are you an in-patient or an outpatient?" << endl;
while (choice != 1 && choice != 2)
{
cout << "If you are an in-patient, press 1" << endl;
cout << "If you are an out-patient, press 2" << endl;
cout << "Enter: ";
cin >> choice;
}
cout << endl << endl;
if (choice == 1)
{
getCharges (num_days, daily_rate, in_med_charge, in_serv_charge);
}
if (choice == 2)
{
getCharges (out_serv_charge, out_med_charge);
}
system("pause");
return 0;
}
// In-Patient Function
double getCharges (int num_days, double daily_rate, double in_med_charge, double in_serv_charge)
{
while (num_days < 0)
{
cout << "Enter Amount of Days Spent: ";
cin >> num_days;
}
if (daily_rate < 0.0)
{
cout << "Daily Rate: $ ";
cin >> daily_rate;
}
if (in_med_charge < 0.0)
{
cout << "Hostpital Medication Charges: $ ";
cin >> in_med_charge;
}
if (in_serv_charge < 0.0)
{
cout << "Hospital Service Charges: $ ";
cin >> in_serv_charge;
}
in_tot_charge = (num_days * daily_rate) + in_med_charge + in_serv_charge;
cout << "In-Patient Total Charges: $ " << in_tot_charge << endl;
cout << endl << endl;
return 0;
}
// Out-Patient Function
double getCharges (double out_serv_charge, double out_med_charge)
{
while (out_serv_charge < 0.0)
{
cout << "Hostpital Service Charges: $ ";
cin >> out_serv_charge;
}
while (out_med_charge < 0.0)
{
cout << "Hostpital Medication Charges: $ ";
cin >> out_med_charge;
}
out_tot_charge = out_serv_charge + out_med_charge;
cout << "Out-Patient Total Charges: $ "<< out_tot_charge << endl;
cout << endl << endl;
return 0;
}
|