Question

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 an out-patient the following data should be entered:
• Charges for hospital services (lab tests, etc.)
• Hospital medication charges.
Use a single, separate function to validate that no input is less than zero. If it is, it should
be re-entered before being returned.
Once the required data has been input and validated, the program should use two
separate functions to calculate the total charges. One of the functions should accept
arguments for the in-patient data, while the other function accepts arguments for out-
patient data. Both functions should return the total charges.

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

CODE:=

def outPatient(charges,medication): # this function return the charges for the out patient
    return charges + medication # simply adding the bills

def inPatient(day,rate,charges,medication): # this returns charges for in patient 
    totalDayCharges = rate*day  # calculating the total days staying cost 
    return totalDayCharges + charges + medication # then adding all the bills

def inPutValidation(value)->float:  # this will validate the inputs from the user 
    while value<0:  # if the value is less than 0 then iterating till user enters positive value
        value = float(input("Enter a positive value: "))
    else:
        return value  # else return the value

inOut = inPutValidation(int(input("The patient was admitted as an in-patient(Enter 1) or an out-patient(Enter 2): ")))
if inOut == 1:  # calculating the charges for in patient 
    day = int(inPutValidation(int(input("The number of days spent in the hospital: "))))
    rate = inPutValidation(float(input("The daily rate: ")))
    charges = inPutValidation(float(input("Charges for hospital services (lab tests, etc.): ")))
    medication = inPutValidation(float(input("Hospital medication charges:")))
    print("Charge for the patient’s hospital stay is", inPatient(day,rate,charges,medication))
if inOut == 2:  # calculating the charges for out patient 
    charges = inPutValidation(float(input("Charges for hospital services (lab tests, etc.): ")))
    medication = inPutValidation(float(input("Hospital medication charges: ")))
    print("Charge for the patient’s hospital stay is",outPatient(charges,medication))

1 test3.py X test2.py test.py X inventory.dat Edef outpatient (charges, medication): # this function return the charges for t

OUTPUT:-

The patient was admitted as an in-patient (Enter 1) or an out-patient (Enter 2): -5 Enter a positive value: 1 The number of d

FOR ANY OTHER QUERY PLEASE COMMENT.

Add a comment
Know the answer?
Add Answer to:
Python language please (also upload the result pic too) Write a program that computes and displays...
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
  • 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...

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

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

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

  • Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to...

    Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program...

    Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program is required that allows a user to encode text using any of three possible ciphers. The three ciphers you are to offer are: Caesar, Playfair and Columnar Transposition. • The program needs to loop, repeating to ask the user if they wish to play with Caesar, Playfair or Columnar Transposition until the user wishes to stop the program. •For encoding, the program needs to...

  • M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a...

    M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a Stereo Receiver Class/Object. INCLUDE IN YOUR ASSIGNMENT At the top of each of your C++ programs, you should have at least four lines of documentation: Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example: // Program name: tictactoe.cpp // Author: Rainbow Dash // Date last updated: 5/26/2016...

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