Question

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 * daily fee for the room), the miscellaneous charges (the total of the medication, surgical, lab, and physical rehabilitation charges), and the total charges. Finally, using a 4th function, display the charges.

There is no validation in this program.

Example Run #1: (bold type is what is entered by the user)

Enter the number of days spent in the hospital: 3

Enter the amount of the medication charges: $125.00

Enter the amount of the surgical charges: $500.00

Enter the amount of the lab fees: $400.00

Enter the amount of the physical rehabilitation charges: $0.00

The cost of the hospital stay is $xxxx.xx

The cost of the miscellaneous charges is $xxxx.xx.

The total cost of the hospital stay is $xxxx.xx.

The example run shows EXACTLY how your program input and output will look.

Write in C, with printf and scanf statements. Create a global constant and use functions.

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

PROGRAM

#include<stdio.h>

float roomRent=3500.00; // Global constant variable "roomRent"

// Declare and implement calCharge() function with one argument "numDays"

float calCharge(int numDays)

{

float stayCharge=roomRent*numDays; // calculate total charge of room rent

return stayCharge; // return total room rent value

}

// Declare and implement misCharge() function with four arguments "medCharge,surCharge,labFee,phyReh"

float misCharge(float medCharge,float surCharge,float labFee,float phyReh)

{

float msc=medCharge+surCharge+labFee+phyReh; // calculate total miscellaneous charge

return msc; // return total miscellaneous charge

}

//Declare and implement totCharge() function with five arguments "numDays,medCharge,surCharge,labFee,phyReh"

float totCharge(int numDays,float medCharge,float surCharge,float labFee,float phyReh)

{

return calCharge(numDays)+misCharge(medCharge,surCharge,labFee,phyReh); // calculate and return total charge

}

// Declare and implement dispCharge() function for displaying charges

void dispCharge(int numDays,float medCharge,float surCharge,float labFee,float phyReh)

{

printf("\nThe cost of the hospital stay is $%.2f",calCharge(numDays)); // display hospital stay charge using calling calCharge() function

printf("\nThe cost of the miscellaneous charges is $%.2f",misCharge(medCharge,surCharge,labFee,phyReh)); // display miscellaneous charge using calling misCharge() function

printf("\nThe total cost of the hospital stay is $%.2f",totCharge(numDays,medCharge,surCharge,labFee,phyReh)); // display total medical charge using calling totCharge() function

}

int main()

{

int nDays; // Declare integer variable nDays

float mChg,sChg,labChg,phyChg; // Declare float variables mChg,sChg,labChg,phyChg

printf("\nEnter the number of days spent in the hospital: ");

scanf("%d",&nDays); // read integer number of days

printf("\nEnter the amount of the medication charges: $");

scanf("%f",&mChg); // read float medical Charge

printf("\nEnter the amount of the surgical charges: $");

scanf("%f",&sChg); // read float surcharge

printf("\nEnter the amount of the lab fees: $");

scanf("%f",&labChg); // read float lab charge

printf("\nEnter the amount of the physical rehabilitation charges: $");

scanf("%f",&phyChg); // read float physical rehabilitation charge

dispCharge(nDays,mChg,sChg,labChg,phyChg); // calling dispCharge() function

return 0;

}

OUTPUT


Enter the number of days spent in the hospital: 3

Enter the amount of the medication charges: $125.00

Enter the amount of the surgical charges: $500.00

Enter the amount of the lab fees: $400.00

Enter the amount of the physical rehabilitation charges: $0.00

The cost of the hospital stay is $10500.00
The cost of the miscellaneous charges is $1025.00
The total cost of the hospital stay is $11525.00

Add a comment
Know the answer?
Add Answer to:
Hospital Charges ASSIGNMENT: Write a program to calculate and display the amount of the charges for...
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
  • 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...

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

    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 Hospital Medication Charges Charges for hospital services (labs, tests, etc.) The program should ask for the following data if the patient was an out-patient: Charges for hospital...

  • 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...

  • 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...

  • Problem: Patient Fees C++ You are to write a program that computes a patient’s bill for...

    Problem: Patient Fees C++ You are to write a program that computes a patient’s 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...

  • 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 program that lets the user enter the total amount of money spent on a...

    Write a program that lets the user enter the total amount of money spent on a credit card for each of 12 months into an array of doubles. The program should calculate and display the total amount of money spent for the year, the average monthly spent, and the months with the highest and lowest amounts. Input Validation: Do not accept negative numbers for monthly credit card charges. If the credit card charge for the month is negative, assume the...

  • Tuition Payment In C++, Write a program that will calculate the total college costs for a...

    Tuition Payment In C++, Write a program that will calculate the total college costs for a student. The program will ask the user for the number of credit hours that the student is taking, the number of lab courses that the student is taking, and whether the student is "in district". The tuition is calculated by multiplying the number of credit hours times the cost per credit plus lab fees. For "in district" students the cost is $70.00 per credit...

  • Using c++ 1 of 2 Assignment 5 Lab Section 3 write a program create a vector...

    Using c++ 1 of 2 Assignment 5 Lab Section 3 write a program create a vector with random numbers. Use merge sort to reorder the vector Prompt user to enter a number to search in the vector. If there are more than one number in the vector equal to the search value, display the indices remove the repeated numbers. If found just one matching number, display the index. If no matching number, prompt user for 2 options: add to the...

  • c++ Write a program that computes and displays the tuition for courses offered at the University....

    c++ Write a program that computes and displays the tuition for courses offered at the University. First, the program should ask if the student has registered for a regular course or a course with a lab component. The user can enter the letter 'C' or 'c' for lecture course only, or the letter 'L' or 'l' for a laboratory course . Write a function called Menu, which takes no input parameters and returns a char value. Your main program will...

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