Hospital Patients 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 Hospital medication charges Charges for hospital services (lab tests, etc.) The program should ask for the following data if the patient was an outpatient: Charges for hospital services (lab tests, etc.) 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 outpatient information. Both functions should return the total charges and display it for the user. After the total charges have been calculated and displayed, write the result to a file, PatientReport.txt. You can use the techniques you learned in Chapter 5, Section 5.11, Using Files for Data Storage. Input Validation: Do not accept negative numbers for any data. For this exercise, you do not need to upload the PatientReport.txt file. It will be created when I run your program.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Exercise 2: Hospital Patients
Write a
-
The number of days spent in the hospital
-
The daily rate
-
Hospital medication charges
-
Charges for hospital services (lab tests, etc.)
The program should ask for the following data if the patient was an outpatient:
-
Charges for hospital services (lab tests, etc.)
-
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 outpatient information. Both functions should return the total charges and display it for the user.
After the total charges have been calculated and displayed, write the result to a file, PatientReport.txt. You can use the techniques you learned in Chapter 5, Section 5.11, Using Files for Data Storage.
Input Validation: Do not accept negative numbers for any data.
For this exercise, you do not need to upload the PatientReport.txt file. It will be created when I run your program.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 11 images