Question

Write a program that computes and displays the charges for a patient’s hospital stay. First, the...

  1. Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask 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:
    1. The number of days spent in the hospital
    2. The daily rate
    3. Hospital Medication Charges
    4. Charges for hospital services (labs, tests, etc.)

The program should ask for the following data if the patient was an out-patient:

  1. Charges for hospital services (labs, tests, etc.)
  2. Hospital Medication Charges

The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for out-patient information. Both functions should return the total charges.

Input Validation: Do not accept negative numbers for any data.

C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include <iostream>

using namespace std;

//Overloaded function declaration
float calculateCharge(int day, float r, float charge, float serviceCharge);
float calculateCharge(float charge, float serviceCharge);

int main()
{
//variables to hold type of patient, days, rate, and charges
char type;
int days;
float rate;
float charges,serviceCharges;
  
//User input for type of patient
cout<<"Admitted as in-patient or out-patient, i/o: ";
cin>>type;
if(type=='i')
{
//Loop till user enter any of negative value
do{
cout<<"The number of days spent in the hospital: ";
cin>>days;
cout<<"The daily rate: ";
cin>>rate;
cout<<"Hospital Medication Charges: ";
cin>>charges;
cout<<"Charges for hospital services (labs, tests, etc.): ";
cin>>serviceCharges;
if(days<0 || rate<0 || charges<0 || serviceCharges<0)
{
cout<<endl<<"None of the value can be negative";
}
}while(days<0 || rate<0 || charges<0 || serviceCharges<0);
  
//call function to calculate totalcharge and print
float totalCharge = calculateCharge(days,rate,charges,serviceCharges);
cout<<endl<<"Total charge: "<<totalCharge;
}
else if(type=='o')
{
//Loop till user enter any of negative value
do
{
cout<<"Hospital Medication Charges: ";
cin>>charges;
cout<<"Charges for hospital services (labs, tests, etc.): ";
cin>>serviceCharges;
if(charges<0 || serviceCharges<0)
{
cout<<endl<<"None of the value can be negative";
cout<<"Re-enter the value";
}
}while(charges<0 || serviceCharges<0);
//call function to calculate total charge and print
float totalMedical = calculateCharge(charges,serviceCharges);
cout<<endl<<"Total charge: "<<totalMedical;
}
else
{
cout<<"Invalid choice";
}
return 0;
}

//function definition to calculate total charge
float calculateCharge(int day, float r, float charge, float serviceCharge)
{
return (day*r) + charge + serviceCharge;
}
float calculateCharge(float charge, float serviceCharge)
{
return charge+serviceCharge;
}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a program that computes and displays the charges for a patient’s hospital stay. First, the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Write a program that computes and displays the charges for a patient's hospital stay_First, the...

    C++ Write a program that computes and displays the charges for a patient's hospital stay_First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: The number of days spent in the hospital The daily rate Charges for hospital services (lab tests, etc.) Hospital medication charges If the patient was an outpatient, the following data should be entered: Charges for hospital services (lab...

  • Python language please (also upload the result pic too) Write a program that computes and displays...

    Python language please (also upload the result pic too) Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask 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 • Charges for hospital services (lab tests, etc.) • Hospital medication charges. If the patient was...

  • Write a python program that computes a patients bill for a hospital stay. The different components of the program are The patientAccount class The Surgery class The Pharmacy class The main program -Th...

    Write a python program that computes a patients bill for a hospital stay. The different components of the program are The patientAccount class The Surgery class The Pharmacy class The main program -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...

  • Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for...

    Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for a hospital stay. Create a global constant for the daily fee of a hospital room ($350.00/day). Ask the user for: The number of days spent in the hospital The amount of the medication charges The amount of the surgical charges The amount of the lab fees The amount of the physical rehabilitation charges Then, using functions, calculate the stay charges (number of days *...

  • Create an application that calculates the total cost of a hospital stay. The application should accept...

    Create an application that calculates the total cost of a hospital stay. The application should accept the following input: the number of days spent in the hospital (as an integer), the amount of medication charges, the amount of surgical charges, the amount of lab fees, and the amount of physical rehabilitation charges. The hospital charges $350 per day. Create the following functions. A. CalcStayCharges- Calculates and returns the base charges for the hospital stay. This is computed as $350 times...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • this is for c++ please and thank you! 19. Check Writer Write a program that displays...

    this is for c++ please and thank you! 19. Check Writer Write a program that displays a simulated paycheck. The program should ask the user to enter the date, the payee's name, and the amount of the check (up to $10,000). It should then display a simulated check with the dollar amount spelled out, as shown here: Date: 11/24/2014 Pay to the Order of: John Phillips $1920.85 One thousand nine hundred twenty and 85 cents Be sure to format the...

  • You are a coding supervisor at a local hospital. You have agreed to accept an HIM...

    You are a coding supervisor at a local hospital. You have agreed to accept an HIM student for their professional practice experience at your facility. Today you are working on coding. You are giving feedback on the codes that the student assigned for the following scenario. Give your feedback to the student, tying your feedback to the Uniform Hospital Discharge Data Set and reimbursement and justify what the correct coding should be. Patient: John Smith MR121212 Acct 000633553 Patient came...

  • please help me with this java problem. using java write an interactive program that will monitor the ?ow of patients in a large hospital. The program should account for patients who check in and out o...

    please help me with this java problem. using java write an interactive program that will monitor the ?ow of patients in a large hospital. The program should account for patients who check in and out of the hospital and should allow access to information about a given patient. In addition, the program should manage the scheduling of three operating rooms. Doctors make a request that includes a patient’s name and a priority value between 1 and 10 that re?ects the...

  • Unplanned hospital readmissions are a serious matter for patients and a quality and cost issue for...

    Unplanned hospital readmissions are a serious matter for patients and a quality and cost issue for the healthcare system of every country. For example, in the United States, during 2011, nearly 19 percent of Medicare patients were readmitted to the hospital within 30 days of their initial discharge, running up an additional $26 billion in healthcare costs. Hospitals are seeking more effective ways to identify patients at high risk of readmission—especially now that Medicare has begun reducing payments to hospitals...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT