Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

**need c++ help in making this program RUN** code need some more function like setmedcost in pharmacy class as in surgery class and in patientAccount

**need c++ help in making this program RUN** code need some more function like setmedcost in pharmacy class as in surgery class and in patientAccount class no input of days stayed is taken in 
daysStayed 

variable for cost calculation.

 #include using namespace std; 
class PatientAccount { private: static float medicinCost, surgCost, totalCost; //set to private and static so they can only be modified from within the program public: int daysStayed, surgNum; //this will account for the number of days stayed in the hospital and the amount of surgeries the patient had //function to update the cost medicine void setMed(float a) { //Check if the medicinCost is less than 0. If so, assign it as 0 if(medicinCost<0) medicinCost=0; //update value with input medicinCost=medicinCost+a; //display new cost cout<<"The updated medicine cost is: $ "< 
class Pharmacy { //Creating private variables private: //creating a double for pharmacy price as private double pharmacyprice; public: //creating double variable named price that will be changed constantly Pharmacy() { pharmacyprice = 0; } double price; //setting pharmacy price equal to price void price(double); pharmacyprice=price; //Creating an accessor for Pharmacy void Pharmacy::pharmacyprice(double price) { //creating doubles and setting values to each double penicillin=10.00, tylenol=8.50, aspirin=6.50, coughsyrup=5.00, mucinex=6.00; //creating an int called choice for future use int choice; //asking a question to user cout<<"Choose which medicine you wish to purchase. "; //creating a while loop that will allow customers to choose which medicine they want to buy. while(choice!=0) { cout<<"0. Confirm purchase "; cout<<"1. Penicillin "; cout<<"2. Tylenol "; cout<<"3. Aspirin "; cout<<"4. Cough Syrup "; cout<<"5, Mucinex "; //Using cin to allow user to submit a number 0-5 cin>>choice; //If statement to set prices depending on which option is chosen if(choice==1) { price+=penicillin; } else if(choice==2) { price+=tylenol; } else if(choice==3) { price+=aspirin; } else if(choice==4) { price+=coughsyrup; } else if(choice==5) { price+=mucinex; } return price; } //Displaying total for the cost of medicine. cout << "Your total amount due is " << price<<". "; } 
class Surgery { private: double SurgCost; //Surgery cost variable public: Surgery() { SurgCost = 0; //constructor to set default price of zero } double general = 10000; double burn = 17500; double heart = 35000; double brain = 40000; //the prices for all 5 types of surgeries double eye = 25300; double setSurgery(int choice) { cout << "Which type of surgery did you have (Input the number)? (Enter zero if no surgery)" << endl; cout << "1. General" << endl; //User picks one of the options. if zero is enter price defaults to zero. cout << "2. Burn" << endl; cout << "3. Heart" << endl; cout << "4. Brain" << endl; cout << "5. Eye" << endl; cin >> choice; if (choice == 1) { SurgCost = general; } else if (choice == 2) { SurgCost = burn; } else if (choice == 3) { SurgCost = heart; } //Sets SurgCost price based off whichever option is picked else if (choice == 4) { SurgCost = brain; } else if (choice == 5) { SurgCost = eye; } else { SurgCost = 0; //Else defaultly sets price to zero if non of the options are picked } return SurgCost; cout << "This surgery's cost: " << SurgCost << endl; } void updatePatient() { [objectname].setSurg(SurgCost) //This is to update the information in the PatientAccount class //Once the int main is made, the object name can go there and then the code will update the surgCost in PaitentAccount Class } }; 

int main()

{

PatientAccount pa;

Pharmacy p;

Surgery s;

int choice;

while(1)

{

s.setSurgery(0); //For allowing user to enter type of surgery

//and default choice set to 0

//cost of surgery according to type will be returned and stored into surgeryCost

p.pharmacyprice(0); //For selecting medicine type and default price set to zero(0)

cout<<"Does patient wants to check out? 1= Yes 2= No";

cin>>ch;

if(ch==1)

break;

}

double total

total=pa.totalExpense(pa.daysStayed);

cout<<"patient checks out with total cost="<

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions