Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am currently working on code for school. I got the code to work, so I d

ID: 3822514 • Letter: H

Question

Hello,

I am currently working on code for school. I got the code to work, so I decided to include a do while loop for the input of surgery_done. I am having a hard time trying to get it to loop correctly.

/*• The names, parameters, and return types of each function and class member
function should be decided in advance.
• The program will be best implemented as a multifile program.

Write a program that computes a patient’s bill for a hospital stay. The different components
of the program are
• The PatientAccount class will keep a total of the patient’s charges. It will also keep
track of the number of days spent in the hospital. The group must decide on the
hospital’s daily rate.
• The Surgery class will have stored within it the charges for at least five types of
surgery. It can update the charges variable of the PatientAccount class.
• The Pharmacy class will have stored within it the price of at least five types of
medication. It can update the charges variable of the PatientAccount class.
• The main program.
The main program will design a menu that allows the user to enter
a type of surgery, enter one or more types of medication, and check the patient out of the
hospital. When the patient checks out, the total charges should be displayed.
*/


#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

class Surgery
{
public:
   static string surgry[];
   static string medications[];
   static float SurgeryCost[];

public:
   float update()
   {
       float surgery_cost;
       cout << "Enter another surgery: ";
       cin >> surgery_cost;
       return (surgery_cost);
   }
};

class Pharmacy
{

public:
   static string medication[];
   static float medicationPriceS[];
   static float cost;
   float getcost() {
       return cost;
   }
   float update(int *x)
   {
       for (int a = 0; a < 5; a = a + 1) {
           cost = cost + x[a];
       }
       return cost;
   }

};

string Surgery::surgry[] = { "Frankenstein Surgery", "Count Dracula Surgery", "Freddy Krueger Surgery", "Wolf Man Surgery", "Mummy Surgery" };

string Pharmacy::medication[] = { "Bath Salts", "Steroids", "Snake Oil", "Poison Ivy", "Blue Pill", "Electric Shock", "Red Pill" };

float Surgery::SurgeryCost[] = { 5000.00, 2000.00, 500.00, 10.00, 800.00 };
float Pharmacy::medicationPriceS[] = { 10.00, 25.00, 5000.00, 5.00, 50.00, 800.00, 55.00 };

float Pharmacy::cost = 0;

class PatientAccount
{
   int day_stay;
   const float day_cost = 400;
   float med_cost, surgery_cost;
   int surgery_return;
   int *phar_return;
   float daycost;
   Surgery srgupdate;
   Pharmacy pharupdate;
public:
   PatientAccount(int days_spent, float surgery, int surg_return, float medicine)
   {
       day_stay = days_spent;
       surgery_cost = surgery;
       med_cost = medicine;
       surgery_return = surg_return;
       daycost = day_cost * days_spent;
   }
public:
   int patient_cost()
   {
       int prices;
       cout << "Press 1 to update the cost of";
       cin >> prices;
       if (prices == 1)
           surgery_cost = srgupdate.update();
       cout << "Press 1 to add more medicine" << "cost: ";
       cin >> prices;
       if (prices == 1)
           med_cost = pharupdate.update(phar_return);
       return (int)(daycost + med_cost + surgery_cost);
   }
};


int main()
{
   int surg_count = 0, surgery_done, days_spent, more_meds;
   float medicine_cost = 0, surgery_cost;
   Surgery surgery_return;
   int phar_count = 0, meds;
   Pharmacy pr;
   static int t = 0;
   int r = 1;
   cout << "Horror Movie Hosiptal ";


   while (surg_count<5)
   {
       cout << surg_count + 1 << " " << Surgery::surgry[surg_count] << " ";
       surg_count++;
   }
   do {
       cout << " Type in the number of the surgery that was performed. ";
       cin >> surgery_done;
       if (surgery_done <= 0 || surgery_done >= 6);
       {cout << "error ";
       cin >> surgery_done;
       }
       while (surgery_done >= 1 || surgery_done <= 5);
       surgery_cost = surgery_return.SurgeryCost[surgery_done - 1];
   }
   while (phar_count < 7);
   {
       cout << phar_count + 1 << " " << Pharmacy::medication[phar_count] << " ";
       phar_count++;
   }
   do {
       cout << " Type in the number of the medicine used. ";
       cin >> meds;
       medicine_cost = medicine_cost + pr.medicationPriceS[meds - 1];
       cout << " Press 1 to enter more medicines: ";
       cin >> more_meds;
   } while (more_meds == 1);

   while (r)
   {
       medicine_cost = medicine_cost + pr.getcost();
       r++;
   }

   cout << "Enter the number of days spent at hospital: ";
   cin >> days_spent;
   PatientAccount pa(days_spent, surgery_cost, surgery_done, medicine_cost);
   cout << " Total charges are: $ " << pa.patient_cost();
   system("Pause");
   return 0;
}

Explanation / Answer

#include <iostream>

using namespace std;

class PatientAccount
{
public:
double totcharges;
int nodays;


int calcharges(int s,int m)
{
int dailyrate=100;
cout<<" Enter No of Days admitted";
cin>>nodays;
int total=s+m+dailyrate;
cout<<" Amount Per day="<<total;
cout<<" Enter the patient discharge or not(Y or N)";
char c;
cin>>c;
  
if(c=='Y')
{
int mnthrate;
mnthrate=total*nodays;
cout<<" Total Bill="<<mnthrate;
}
  
}
  
};


class Surgery
{
public:
int BreastSurgery()
{
int BreastSurgery=2000;
cout<<BreastSurgery;
return BreastSurgery;
}
int EndocrineSurgery()
{
int EndocrineSurgery=3000;
return EndocrineSurgery;
}
int GeneralSurgery()
{
int GeneralSurgery=4000;
return GeneralSurgery;
}
int HandSurgery()
{
int HandSurgery=5000;
return HandSurgery;
}
int OrthopedicSurgery()
{
int OrthopedicSurgery=2500;
return OrthopedicSurgery;
}
  
  
};

class Phamacy
{
public:
int LabTest()
{
int LabTest=500;
cout<< LabTest;
return LabTest;
}
int xray()
{
int xray=300;
return xray;
}
int bloodtest()
{
int bloodtest=450;
return bloodtest;
}
int pulseTest()
{
int pulseTest=400;
return pulseTest;
}
int generalTest()
{
int generalTest=600;
return generalTest;
}
};
int main()
{
cout<<" ============================================================================= ";
cout<<" PATIENT BILLING ";
cout<<" ============================================================================= ";
cout<<" Types of Surgery In Hospital";
cout<<" ============================================================================= ";
cout<<" 1.BreastSurgery";
cout<<" 2.EndocrineSurgery";
cout<<" 3.GeneralSurgery";
cout<<" 4.HandSurgery";
cout<<" 5.OrthopedicSurgery";
cout<<" ============================================================================= ";
cout<<" Types of Medication In Hospital";
cout<<" ============================================================================= ";
cout<<" 1.LabTest";
cout<<" 2.xray";
cout<<" 3.bloodtest";
cout<<" 4pulseTest";
cout<<" 5.generalTest";
cout<<" ============================================================================= ";
PatientAccount p;
Surgery s;
Phamacy p1;int scharges,mcharges;
int typeSurgery;
int typem;

cout<<" Enter Type of Surgery";
cout<<" 1.BreastSurgery";
cout<<" 2.EndocrineSurgery";
cout<<" 3.GeneralSurgery";
cout<<" 4.HandSurgery";
cout<<" 5.OrthopedicSurgery";
cin>>typeSurgery;
cout<<" ============================================================================= ";

switch(typeSurgery)
{
case 1:
scharges=s.BreastSurgery();
break;
case 2:
scharges=s.EndocrineSurgery();
break;
case 3:
scharges= s.GeneralSurgery();
break;
  
case 4:
scharges=s.HandSurgery();
break;
case 5:
scharges= s.OrthopedicSurgery();
break;
default:
cout<<"Enter valid choice";
}
cout<<" Enter Type of Medication";
cout<<" ============================================================================= ";
cout<<" 1.LabTest";
cout<<" 2.xray";
cout<<" 3.bloodtest";
cout<<" 4.pulseTest";
cout<<" 5.generalTest";
cin>>typem;
switch(typem)
{
case 1:
mcharges= p1.LabTest();
break;
case 2:
mcharges= p1.xray();
break;
case 3:
mcharges=p1.bloodtest();
break;
  
case 4:
mcharges=p1.pulseTest();
break;
case 5:
mcharges= p1.generalTest();
break;
default:
cout<<"Enter valid choice";
}


p.calcharges(scharges,mcharges);
  


return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote