QuestionQuestion

Overloaded functions
Write a program that computes and displays charges for a patient’s hospital stay. First, the program should ask if the patient was an in-patient or an out-=patient. For an in-patient the following applies:
• The number of days spent in the hospital
• The daily rate
• Hospital medication charges.
• Charges for hospital services (x-rays, lab tests, etc.)

The program should then ask for the following charges if the patient was an out-patient:
• Hospital medication charges.
• Charges for hospital services (x-rays, lab tests, etc.)

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

Input validation: Do not accept negative numbers for data.
You must include an IPO or pseudo-code for your program for full credit.
Your output must be formatted to no more than 2 decimal places and don’t forget the $ sign.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

/*
Pseudocode (Algorithm) for main function:
    Declare variable for patient type (char)
    Declare variable for number of days (int)
    Declare variable for daily rate (float)
    Declare variable for hospital medication charges (float)
    Declare variable for charges for hospital services (float)
    Declare variable for total charges (float)
    Prompt user for patient type (i for in-patient and o for out-patient)
    Save the answer to variable
    If the answer is not i or o:
      Print error message
      Exit the program
    If the patient type is in:
      Prompt user for the number of days spent in hospital
      Save the answer to variable
      If the answer is negative:
       Print error message
       Exit the program
      Prompt user for the daily rate
      Save the answer to variable
      If the answer is negative:
       Print error message
       Exit the program
    Prompt user for the hospital medication charges
    Save the answer to variable
    If the answer is negative:...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Computer Science - Other Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats