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

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

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

  • Please help me to write a c++ program that will Implement a HotelRoom class, with private...

    Please help me to write a c++ program that will Implement a HotelRoom class, with private data members: the room number, room capacity (representing the maximum number of people the room can accommodate), the occupancy status (0 or the number of occupants in the room), the daily room rate. Member functions include: • a 4-argument constructor that initializes the four data members of the object being created (room number, room capacity, room rate, occupancy status) to the constructor's arguments. The...

  • Answer in C using basic C and loops. ASSIGNMENT: Write a program that will display how...

    Answer in C using basic C and loops. ASSIGNMENT: Write a program that will display how many times a ball will bounce until its height is less than 1 inch. A ball has a property called the coefficient of restitution, a number between 0.0 and 1.0, that indicates how 'bouncy' the ball is. A coefficient of restitution of .5 means that the ball will bounce-up 50% of its initial height after each bounce Write a program to ask the user...

  • Write, compile, and test a C++ program that uses a loop to calculate and display each...

    Write, compile, and test a C++ program that uses a loop to calculate and display each employee’s weekly pay and the accumulated total pay for the company. The program will first ask the user for the number of employees. It will then ask for the number of hours and rate of pay for each employee and display the calculated pay for each employee. EXAMPLE RUN (user input appears in blue and bold): Enter number of employees: 3 Hours: 5 Rate...

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