$30
CMPT220 - Program 3 Bring hardcopy to class to turn in Name the project Prog3YourLastName Name the class HospitalYourLastName The purpose of this program is to master conditional statements and loops. This program will once again help our Hospital process insurance payments. You’ll need to make a copy of your project – see back of this page. 1) Patients are charged based on their Insurance Plan, their total Household Income (which cannot be negative), and the number of days they stay in the hospital (which could be from 1 day to one year). All patients are charged an Admittance Fee of $300 when they are admitted to the hospital. Patients are also charged a Service Fee, based on the chart described in step 2. However, long-term patients receive a Discount of $250 for every week they stay in the hospital. A long-term patient is one who stays more than 23 days. 2) The Per Diem Rate is computed from the following table, based on Insurance Plan and Household Income: Insurance Plan Household Income Per Diem (charge per day) Red Cross less than $15,000 $50 $15,000 - $37,500 $70 more than $37,500 $150 Mid-Hudson less than $20,000 $40 $20,000 - $45,000 $75 more than $45,000 $110 ACA less than $12,500 $60 $12,500 - $53,000 $75 more than $53,000 $140 No Insurance All income brackets $350 The Service Fee is the Per Diem multiplied by the number of days in the hospital. 3) The Discount (if any) is the number of weeks in the hospital multiplied by $250.00. This only applies to long-term patients. 4) The Total Bill is calculated by adding the Admittance Fee to the Service Fee, then subtracting any Discount. For a patient, your program asks for the following (in this order!): Patient ID -- any integer, ** Household Income – a double, ** Insurance Plan – a single character, ‘R’ for Red Cross, ‘M’ for Med-Hudson ‘A’ for ACA, ‘N’ for No Insurance ** Number of Days -- an integer. ** means the value must be validated!!! The program computes all of the charges and prints out the Patient ID number, Household Income, full name of the Insurance Plan, Number of Days, Admittance Fee, Per Diem Rate, Service Fee, Discount, and Total Bill. (Use a switch statement on Insurance Plan, then a nested if-else to determine the Per Diem rate.) Remember to greet the user, use mnemonic variable names, to prompt the user for input, and to properly label and format the output (use a dollar sign, 2 digits after the decimal point, etc., on output) and to say Good-bye! Make the following modifications to your Program2. Be sure to validate the input as described on page 1. Add a “big” while loop, which will allow your program to work for multiple patients. This “big” loop will have as its body most of the code you wrote for Program 2, plus a bit more. Your program will allow the user to enter patient data for multiple patients. You’ll still print out information about each individual patient. Your program will continue to run until the user enters the value 0 (zero) for a Patient ID. (Inputting the number zero for the patient ID will terminate the loop.) [HINT: Should this “big” loop be a pre-condition loop or a postcondition loop? Why?] (Ask for the patient ID before the loop, and then again at the end of the loop.) You will want to keep track of the following values: • the number of patients processed, • the highest Bill paid, • the Patient ID associated with the highest Bill, • the total sum of all Bills processed, and • the average Bill amount. [HINT: Which of these can you determine inside the big loop and which of these must you wait until after the big loop is finished?] As you process each patient’s bill, you’ll print out the data about that bill, just like you did in Program 2. After the user enters a Patient ID of 0, your program will print a summary including the number of patients processed, the highest Bill paid, the patient ID associated with the highest bill, the total amount of all bills processed, and the average bill amount, in this order, each on a line by itself. Of course, you’ll want to label and properly format these, too! You’ll need to make a copy of your Prog2YourLastName project: • In Eclipse, in the Package Explorer, right-click on your Prog2YourLastName project and select Copy. • Then right-click again, and choose Paste. • A dialog will pop up, asking for the new project name. Call it Prog3YourLastName and click Copy. • The new project will appear in the Package Explorer. Use that new project for this assignment. (Be sure to “Close Editor” for Prog2!)