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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
// MAIN
#include <iostream>
#include "PatientAccount.h"
#include "Pharmacy.h"
#include "Surgery.h"
#include <iomanip>
using namespace std;
int main()
{
Surgery type;
Pharmacy meds;
PatientAccount charges;
double mCharge = 0, // Surgery charge;
ttlMCharge;
char sType, // type of surgery chosen by user
mType, // types of medications chosen by user
choice;
cout << "To obtain the total patient hospital charges, first choose the type of surgery," << endl
<< "then choose the medications used by the patient. " << endl << endl
<< "What is the type of surgery?" << endl
<< "Enter (B) for back surgery" << endl
<< "Enter (H) for hip surgery" << endl
<< "Enter (S) for shoulder surgery" << endl
<< "Enter (F) for foot surgery" << endl
<< "Enter (X) for hand surgery" << endl;
cin >> sType;
type.chooseSurgery(sType);
do
{
cout << endl << "Enter the medications used by the patient" << endl << endl
<< "Enter (V) for Vicodin" << endl
<< "Enter (O) for OxyContin" << endl
<< "Enter (I) for Ibuprofen" << endl
<< "Enter (P) for Percocet" << endl
<< "Enter (C) for Celebrex" << endl;
cin >> mType;
meds.chooseMeds(mType);
cout << endl << "Do you want to add another medication?" << endl
<< "Enter (Y) for yes. Enter (N) to check the patient out of the hospital and" << endl
<< "see the total charges." << endl;
cin >> choice;
} while (choice == 'Y' || choice == 'y');
cout << fixed << showpoint << setprecision(2)
<< "The total charges is: $" << charges.ttlMedsCharges(mCharge, ttlMCharge) << endl;
return 0;
}
===============================
// Surgery header
#ifndef SURGERY_H
#define SURGERY_H
#include "PatientAccount.h"
// Surgery class declaration
class Surgery
{
private:
double sCharge, // Surgery charge;
ttlHCharge;
int days, // # of days a patient must stay in the hospital
dailyRate = 200; // Daily rate of hospital stay is $200/day
PatientAccount charge; // charge is an instance of the PatientAccount class
public:
void chooseSurgery(char);
void totalHospCharges(double, double, int, int);
};
#endif
=========================
// Surgery functions
#include <iostream>
#include <string>
#include "Surgery.h"
using namespace std;
void Surgery::chooseSurgery(char sType)
{
// Process menu selection
switch (sType)
{
// In-patient
case 'b':
case 'B':
sCharge = 50000; // Cost of back surgery is $50,000
days = 4;
break;
case 'h':
case 'H':
sCharge = 20000; // Cost of hip surgery is $20,000
days = 3;
break;
case 's':
case 'S':
sCharge = 10000; // Cost of shoulder surgery is $10,000
days = 3;
break;
case 'f':
case 'F':
sCharge = 5000; // Cost of foot surgery is $5,000
days = 1;
break;
case 'x':
case 'X':
sCharge = 8000; // Cost of hand surgery is $8,000
days = 1;
break;
}
totalHospCharges(sCharge, ttlHCharge, dailyRate, days);
}
void Surgery::totalHospCharges(double sCharge, double ttlHCharge, int dailyRate, int days)
{
charge.ttlHospCharges(sCharge, ttlHCharge, dailyRate, days);
}
===========================
// Pharmacy header
#ifndef PHARMACY_H
#define PHARMACY_H
#include "PatientAccount.h"
// Pharmcy class declaration
class Pharmacy
{
private:
double mCharge, // Surgery charge;
ttlMCharge = 0;
PatientAccount charge; // charge is an instance of the PatientAccount class
public:
void chooseMeds(char);
void totalMedsCharges(double, double&);
};
#endif
==========================
// Pharmacy functions
#include <iostream>
#include <string>
#include "Pharmacy.h"
using namespace std;
void Pharmacy::chooseMeds(char mType)
{
// Process menu selection
switch (mType)
{
case 'v':
case 'V':
mCharge = 200; // Cost of 30 day supply Vicodin is $200
break;
case 'o':
case 'O':
mCharge = 300; // Cost of 30 day supply OxyContin is $300
break;
case 'i':
case 'I':
mCharge = 10; // Cost of 30 day supply Ibuprofen is $10
break;
case 'p':
case 'P':
mCharge = 450; // Cost of 30 day supply Percocet is $450
break;
case 'c':
case 'C':
mCharge = 250; // Cost of 30 day supply Celebrex is $250
break;
}
totalMedsCharges(mCharge, ttlMCharge);
}
void Pharmacy::totalMedsCharges(double mCharge, double &ttlMCharge)
{
charge.ttlMedsCharges(mCharge, ttlMCharge);
}
==================================
// Patient account header
#ifndef PATIENTACCOUNT_H
#define PATIENTACCOUNT_H
// PatientAccount class declaration
class PatientAccount
{
private:
double sCharge, // total of patient charges
ttlHCharge,
mCharge,
ttlMCharge,
ttlPCharge;
int days,
dailyRate;
public:
void ttlHospCharges(double, double, int, int);
double ttlMedsCharges(double, double&);
};
#endif
=======================
// Patient Account functions
#include <iostream>
#include <string>
#include "PatientAccount.h"
using namespace std;
void PatientAccount::ttlHospCharges(double sCharge, double ttlHCharge, int dailyRate, int days)
{
ttlHCharge = sCharge + (days * dailyRate);
}
double PatientAccount::ttlMedsCharges(double mCharge, double &ttlMCharge)
{
ttlMCharge = ttlMCharge + mCharge;
return ttlMCharge;
}
|