Saturday, January 7, 2017

Programming Challenge 6.15 - Overloaded Hospital

/* Overloaded Hospital - This program computes and displays the charges
   for a patient's hospital stay. First the program asks if the patient
   was admitted as an in-patient or an out-patient. If the patient was
   an in-patient, the following data should be entered:
 
   * The number of days spent in the hospital
   * The daily rate
   * Hospital medication charges
   * Charges for hospital services (lab tests, etc.)

   If the patient was an out-patient, the following data should be
   entered:

   * Charges for hospital services (lab tests, etc.)
   * Hospital medication charges

   This program uses two overloaded functions:

   * getPatientData()
   * getPatientData()

   Input Validation: This program does not accept negative numbers for
   any data. */

/* Function Prototypes: Get patient data, Get patient data */
double getPatientData(int, double, double, double);
double getPatientData(double, double);

#include "Utility.h"

int main()
{
   /* Constants: Menu items */
   const int INPATIENT_BILLING_SYSTEM = 1,
             OUTPATIENT_BILLING_SYSTEM = 2,
             QUIT = 3;

   /* Variables: Daily rate, Medication charges, Hospital service charges,
                 Inpatient and outpatient total charges */
   double dailyRate = 0.0,
          medCharges = 0.0,
          serviceCharges = 0.0,
          totalCharges = 0.0;

   /* Variable: Number of days, Menu choice */
   int numDays = 0,
       menuChoice = 0;

   do
   {
      /* Display: The menu, Ask if the patient was an in- or an
                  out-patient and get the according menu choice
                  from the user */
      cout << "\t\tXanth University Hospital Billing System\n"
           << "\t\t----------------------------------------\n\n"
           << "Please enter the necessary data for Com Passion\n"
           << "to compute the total charges of our (un)lucky\n"
           << "patients who survived Prof. Grossclout's harsh\n"
           << "curing methods.\n\n"
           << "Was the patient:\n\n"
           << "1.> An In-Patient?\n"
           << "2.> An Out-Patient?\n"
           << "3.> Quit\n\n"
           << "Your choice is: ";
      cin >> menuChoice;

      /* Validate: Menu choice */
      while (menuChoice < 1 || menuChoice > 3)
      {
         cout << "\nMENU CHOICE INVALID - CHANGING REALITY\n"
              << "GRAC'L SKELETON CHANGES INPUT TO 1 TO ENTER\n"
              << "DATA FOR IN-PATIENTS, 2 TO ENTER DATA FOR OUT-\n"
              << "PATIENTS, OR 3 TO QUIT!\n";
         cin >> menuChoice;

         catchInfiniteLoop();
      }

      /* Get: The patient data while menu choice is not quit */
      if (menuChoice != QUIT)
      {
         switch (menuChoice)
         {
            case INPATIENT_BILLING_SYSTEM:
             
               /* Display: Patient type, Patient name */
               cout << "\nBilling Information for "
                    << "In-Patient: Jenny Elf" << endl;

               /* Get: Billing Information */
               cout << "\nDuration of stay: ";
               cin >> numDays;

               /* While the input is un-Com Passionable, the following
               message will be displayed */
               while (numDays < 0)
               {
                  cout << "\nCAN NOT CO(M)PUTE - CHANGING REALITY!\n"
                       << "ENTRY FOR DURATION OF STAY IS REPEA(t)ED: ";
                  cin >> numDays;

                  catchInfiniteLoop();
               }

               cout << "Daily rate for this patient: X$ ";
               cin >> dailyRate;

               /* While the input is un-Com Passionable, the following
               message will be displayed */
               while (dailyRate < 0)
               {
                  cout << "\nCAN NOT CO(M)PUTE - CHANGING REALITY!\n"
                       << "ENTRY FOR DAILY RATE IS REPEA(t)ED: ";
                  cin >> dailyRate;

                  catchInfiniteLoop();
               }

               cout << "Medication charges for this patient X$: ";
               cin >> medCharges;

               /* While the input is un-Com Passionable, the following
               message will be displayed    */
               while (medCharges < 0)
               {
                  cout << "\nCAN NOT CO(M)PUTE - CHANGING REALITY!\n"
                     << "ENTRY FOR MEDICATION CHARGES IS REPEA(t)ED: ";
                  cin >> medCharges;

                  catchInfiniteLoop();
               }

               cout << "Hospital service charges X$: ";
               cin >> serviceCharges;

               /* While the input is un-Com Passionable, the following
               message will be displayed    */
               while (serviceCharges < 0)
               {
                  cout << "\nCAN NOT CO(M)PUTE - CHANGING REALITY!\n"
                       << "ENTRY FOR SERVICE CHARGES IS REPEA(t)ED: ";
                  cin >> serviceCharges;

                  catchInfiniteLoop();
               }

               /* Call: getPatientData */
               totalCharges = getPatientData(numDays, dailyRate,
                              medCharges, serviceCharges);

               /* Set up: Numeric output format */
               cout << fixed << showpoint << setprecision(2);

               /* Display: Billing Data */
               cout << "\n\t\tTotal Charges For Treatment Of Jenny Elf\n"
                    << "\t\t----------------------------------------\n\n"
                    << "Days Of Stay: "
                    << setw(42) << right << numDays
                    << "\nMedication Charges:"
                    << "\nDaily Rate:"
                    << setw(37) << right << "X$ "
                    << setw(8) << right << dailyRate
                    << "\nMedication Charges:"
                    << setw(29) << right << "X$ "
                    << setw(8) << right << medCharges
                    << "\nService Charges:"
                    << setw(32) << right << "X$ "
                    << setw(8) << right << serviceCharges
                    << "\n\t\t-----------------------------------------\n"
                    << "Total Charges:"
                    << setw(34) << right << "X$ "
                    << setw(8) << right << totalCharges;

               cout << "\n\nN(e)Xt!\n\n";
               break;

            case OUTPATIENT_BILLING_SYSTEM:

               /* Display: Patient type, Patient name */
               cout << "\nBilling Information for "
                    << "Out-Patient: Che Centaur" << endl;

               /* Get: Billing Information */
               cout << "\nMedical charges for this patient X$: ";
               cin >> medCharges;

               /* While the input is un-Com Passionable, the following
               message will be displayed    */
               while (medCharges < 0)
               {
                  cout << "\nCAN NOT CO(M)PUTE - CHANGING REALITY!\n"
                       << "ENTRY FOR MEDICATION CHARGES IS REPEA(t)ED: ";
                  cin >> medCharges;

                  catchInfiniteLoop();
               }

               cout << "Hospital service charges X$: ";
               cin >> serviceCharges;

               /* While the input is un-Com Passionable, the following
               message will be displayed    */
               while (serviceCharges < 0)
               {
                  cout << "\nCAN NOT CO(M)PUTE - CHANGING REALITY!\n"
                       << "ENTRY FOR SERVICE CHARGES IS REPEA(t)ED: ";
                  cin >> serviceCharges;

                  catchInfiniteLoop();
               }

               /* Call: getPatientData */
               totalCharges = getPatientData(medCharges, serviceCharges);

               /* Set up: Numeric output format */
               cout << fixed << showpoint << setprecision(2);

               /* Display: Billing Data */
               cout << "\n\t\tTotal Charges For Treatment Of Che Centaur\n"
                    << "\t\t------------------------------------------\n"
                    << "\nMedication Charges:"
                    << setw(31) << right << "X$ "
                    << setw(8) << right << medCharges
                    << "\nService Charges:"
                    << setw(34) << right << "X$ "
                    << setw(8) << right << serviceCharges
                    << "\n\t\t------------------------------------------\n"
                    << "Total Charges:"
                    << setw(36) << right << "X$ "
                    << setw(8) << right << totalCharges;

               cout << "\n\nN(e)Xt!\n\n";
               break;
         }
      }

      if (menuChoice == QUIT)
      {
         cout << "\nOh Cruel World! Another Patient Survived, Ent Left ...\n";
         cin.ignore();
      }
   } while (menuChoice != QUIT);

   pauseSystem();
   return 0;
}

/* **********************************************************
   Definition: getPatientData

   This overloaded function accepts the following in-patient
   information as arguments:
 
   * The number of days spent in the hospital
   * The daily rate
   * Hospital medication charges
   * Charges for the hospital services (lab tests, etc.)
 
   It calculates and returns the total charges for the in-
   patients stay.
   ********************************************************** */

double getPatientData(int numDays, double dailyRate, double medCharges,
                      double serviceCharges)
{
   /* Variable: Total patient charges */
   double inpatientChargesTotal = 0.0;

   /* Calculate: The total charges */
   inpatientChargesTotal = (dailyRate * numDays) +
                           (medCharges + serviceCharges);

   /* Return: Total charges */
   return inpatientChargesTotal;
}

/* **********************************************************
   Definition: getPatientData

   This overloaded function accepts the following out-patient
   information as arguments:
 
   * Hospital medication charges
   * Charges for the hospital services (lab tests, etc.)
 
   It calculates and returns the total charges for the in-
   patients stay.
   ********************************************************** */

double getPatientData(double medCharges, double serviceCharges)
{
   /* Variable: Total patient charges */
   double outpatientChargesTotal = 0.0;

   /* Calculate: Total charges */
   outpatientChargesTotal = (medCharges + serviceCharges);

   /* Return: Total charges */
   return outpatientChargesTotal;
}

2 comments:

  1. I am 29 years old and have been diagnosed with breast cancer, ease of treatment and a similar story, except for my first acceptance as a rejection of herbal medicine. I was not part of the Perseid movement and did not really build relationships with any of them, I just believed in their operation. I say this because it was during the use of Dr. Itua herbal medicine that I now attest that herbal medicine is real, the phytotherapy Dr. Itua heal my breast cancer which I suffered for 2 years. Dr. Itua herbal medicine is made of natural herbs, with no side effects, and easy to drink. If you have the same breast cancer or any type of human illness, including HIV / AIDS, herpes cancer,Ovarian Cancer,Pancratics cancers, bladder cancer, bladder cancer, prostate cancer, Glaucoma., Cataracts,Macular degeneration,Cardiovascular disease,Autism,Lung disease.Enlarged prostate,Osteoporosis.Alzheimer's disease,psoriasis ,Tach Diseases,Lupus,
    Dementia.kidney cancer, lung cancer, skin cancer, skin cancer and skin cancer.testicular Cancer, , LEUKEMIA, VIRUSES, HEPATITIS, INFERTILITY WOMEN / MAN, LOT OF LOVE, LOTTERY. ITS CONTACT EMAIL / WHATSAPP: Or drituaherbalcenter@gmail.com/ +2348149277967
    Here is my contact phone number. +1-913-9518-145 if you would need some advise from me.

    ReplyDelete
  2. I'm 55-year-old from Korean, I was diagnosed with second-stage liver cancer following a scheduled examination to monitor liver cirrhosis. I had lost a lot of weight. A CT scan revealed three tumors; one in the center of my liver in damaged tissue and two in healthy portions of my liver. No chemotherapy or radiotherapy treatment was prescribed due to my age, the number of liver tumors. One month following my diagnosis I began taking 12 (350 point) Salvestrol supplements per day, commensurate with my body weight. This comprised six Salvestrol Shield (350 point) capsules and six Salvestrol Gold (350 point) capsules, spread through the day by taking two of each capsule after each main meal. This level of Salvestrol supplementation (4,000 points per day) was maintained for four months. In addition, I began a program of breathing exercises, chi exercises, meditation, stretching and stress avoidance. Due to the variety of conditions that I suffered from, I received ongoing medical examinations. Eleven months after commencing Salvestrol supplementation But all invalid so I keep searching for a herbal cure online that how I came across a testimony appreciating Dr Itua on how he cured her HIV/Herpes, I contacted him through email he listed above, Dr Itua sent me his herbal medicine for cancer to drink for two weeks to cure I paid him for the delivering then I received my herbal medicine and drank it for two weeks and I was cured until now I'm all clear of cancer, I will advise you to contact Dr Itua Herbal Center On Email...drituaherbalcenter@gmail.com. WhatsApps Number...+2348149277967. If you are suffering from Diseases listed below, Cancer, HIV/Aids, Herpes Virus,Bladder cancer,Brain cancer,Colon-Rectal Cancer,Breast Cancer,Prostate Cancer,
    ?Esophageal cancer,?Gallbladder cancer,Gestational trophoblastic disease,Head and neck cancer,?Hodgkin lymphoma
    ?Intestinal cancer,Kidney cancer,Leukemia,Liver cancer,Lung cancer,Melanoma,Mesothelioma,?Multiple myeloma,?Neuroendocrine tumors,Non-Hodgkin lymphoma,?Oral cancer,Ovarian cancer,?Sinus cancer,Skin cancer,Soft tissue sarcoma,Spinal cancer,Stomach cancer,Testicular cancer,Throat cancer,Thyroid Cancer,?Uterine cancer,Vaginal cancer,Als,Vulvar cancer,Hepatitis, Chronic Illness. Lupus,Fibromyalgia.

    ReplyDelete