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

Hello I have a C++ problem. I am having problems displaying the calculations on

ID: 3821590 • Letter: H

Question

Hello I have a C++ problem. I am having problems displaying the calculations on this project.

16. Patient Fees
Here are some suggestions:

• 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.

Here is the code so far

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class surgery {
public:
   static string surgry[];
   static string medications[];
   static float PriceS[];
public:
   float update() {
       float cost;
       cout << "Enter the updated surgery cost: ";
       cin >> cost;
       return (cost);
   }
};
class pharmacy {
public:
   static string medication[];
   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[] = { "Breast Health Surgery",
"Cardiac Surgery","Eye Surgery","General Surgery","Ear Surgery" };
string pharmacy::medication[] = { "Wellbutrin", "Prozac", "Straterra", "Adderall", "Ibuprofen" ,"Codein", "Vicodin" };
float surgery::PriceS[] = { 100.00,700.00,500.00,800.00,900.00 };
float pharmacy::cost = 0;

class PatientAccount
{
   int days;
   float mcost, scost;
   int sr;
   int *ar;
   surgery srg;
   pharmacy prm;
public:
   PatientAccount(int d, float s, int sre, float m, int x[])
   {
       days = d;
       scost = s;
       mcost = m;
       sr = sre;

   }
public:
   int charges()
   {
       int ch;
       cout << "Press 1 to update the cost of";
       cin >> ch;

       if (ch == 1)
           scost = srg.update();

       cout << "Press 1 to update the medicines" << "cost: ";
       cin >> ch;

       if (ch == 1)
           mcost = prm.update(ar);

       return (int)(days*mcost + scost);
   }
};
int main()
{
   int i = 0, surgery_done, d, n;
   float medicine_cost = 0, surgery_cost;
   surgery sr;
   int j = 0, x[7];
   pharmacy pr;
   static int t = 0;
   int r = 1;
   cout << "Welcome to hospital billing";
   cout << " Type of surgeries available ";
   while (i<5)
   {
       cout << i + 1 << " " << surgery::surgry[i] << " ";
       i++;

   }
   cout << " Enter the surgery done: ";
   cin >> surgery_done;
   surgery_cost = sr.PriceS[surgery_done - 1];
   cout << "Types of medication available ";
   while (j<7)
   {
       cout << j + 1 << " " << pharmacy::medication[j] << " ";

       j++;
   }
   do {
       cout << "Enter the medication use: ";
       cin >> x[t];
       t++;
       cout << " Press 1 to enter more medicines: ";
       cin >> n;
   } while (n == 1);

   while (r)
   {
       medicine_cost = medicine_cost + pr.getcost();
       r++;
   }
   cout << "Enter the number of days spent at hospital: ";
   cin >> d;
   PatientAccount pa(d, surgery_cost, surgery_done, medicine_cost, x);
   cout << " Total charges are: $ " << medicine_cost;

   system("Pause");
   return 0;
}

Explanation / Answer

// need more info for the update logic rest all program is working fine

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class surgery {
public:
   static string surgry[];
   //static string medications[];
   static float SurgeryPriceS[];
public:
   float update() {
       float cost;
       cout << "Enter the updated surgery cost: ";
       cin >> cost;
       return (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[] = { "Breast Health Surgery",
"Cardiac Surgery", "Eye Surgery", "General Surgery", "Ear Surgery" };
string pharmacy::medication[] = { "Wellbutrin", "Prozac", "Straterra", "Adderall", "Ibuprofen", "Codein", "Vicodin" };
float surgery::SurgeryPriceS[] = { 100.00, 700.00, 500.00, 800.00, 900.00 };
float pharmacy::medicationPriceS[] = { 100.00, 700.00, 500.00, 800.00, 900.00, 800.00, 900.00 };

float pharmacy::cost = 0;
class PatientAccount
{
   int days;
   const float daycharge = 200;
   float mcost, scost;
   int sr;
   int *ar;
   float daycost;
   surgery srg;
   pharmacy prm;
public:
   PatientAccount(int d, float s, int sre, float m)
   {
       days = d;
       scost = s;
       mcost = m;
       sr = sre;
       daycost = daycharge * d;
   }
public:
   int charges()
   {
       int ch;
       cout << "Press 1 to update the cost of";
       cin >> ch;
       if (ch == 1)
           scost = srg.update();
       cout << "Press 1 to update the medicines" << "cost: ";
       cin >> ch;
       if (ch == 1)
           mcost = prm.update(ar);
       return (int)(daycost + mcost + scost);
   }
};
int main()
{
   int i = 0, surgery_done, d, n;
   float medicine_cost = 0, surgery_cost;
   surgery sr;
   int j = 0, x;
   pharmacy pr;
   static int t = 0;
   int r = 1;
   cout << "Welcome to hospital billing";
   cout << " Type of surgeries available ";
   while (i<5)
   {
       cout << i + 1 << " " << surgery::surgry[i] << " ";
       i++;
   }
   cout << " Enter the surgery done: ";
   cin >> surgery_done;
   surgery_cost = sr.SurgeryPriceS[surgery_done - 1];
   cout << "Types of medication available ";
   while (j<7)
   {
       cout << j + 1 << " " << pharmacy::medication[j] << " ";
       j++;
   }
   do {
       cout << "Enter the medication use: ";
       cin >> x;
       medicine_cost = medicine_cost + pr.medicationPriceS[x - 1];
       cout << " Press 1 to enter more medicines: ";
       cin >> n;
   } while (n == 1);
/*   while (r)
   {
       medicine_cost = medicine_cost + pr.getcost();
       r++;
   }*/
   cout << "Enter the number of days spent at hospital: ";
   cin >> d;
   PatientAccount pa(d, surgery_cost, surgery_done, medicine_cost);
   cout << " Total charges are: $ " << pa.charges();
   system("Pause");
   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