Question: Complete the program below so that it produces the correct output. For example: Provided Code: hospital_charges.rb: require './input_functions' def read_patient_name() # write this function -

Complete the program below so that it produces the correct output. For example:

Complete the program below so that it produces the correct output. For

Provided Code: hospital_charges.rb:

require './input_functions'

def read_patient_name()

# write this function - use the function read_string(s)

# from input_functions.rb to read in the name

# make sure you 'return' the name you read to the calling module

name = read_string('Enter patient name: ')

return name

end

def calculate_accommodation_charges()

charge = read_float("Enter the accommodation charges: ")

return charge

end

def calculate_theatre_charges()

charge = read_float("Enter the theatre charges: ")

return charge

end

def calculate_pathology_charges()

# complete this function based on the above examples

end

def print_patient_bill(name, total)

# write this procedure to print out the patient name

# and the bill total - use the procedure (from input_functions)

# print_float(value, decimal_places) to print the total

end

def create_patient_bill()

total = 0 # it is important to initial variables before use!

patient_name = read_patient_name()

total += calculate_accommodation_charges()

total += calculate_theatre_charges()

total += calculate_pathology_charges()

print_patient_bill(patient_name, total)

end

def main()

create_patient_bill()

end

main()

Complete the program below so that it produces the correct output. For example: Enter patient name: Sam Jones Enter the accommodation charges: 23.50 Enter the theatre charges: 45.99 Enter the pathology charges: 59.20 The patient name: Sam Jones The total amount due is: $128.69 Steps in the program: Read in the patient's name (you need to write this - use the function from the file NOTE: You do not need to copy in the functions from - they are available because of the line at the top of the program. Calculate the accommodation charges (these are just read in) Calculate the theatre charges (these are just read in) Read in the pathology charges (you need to write this to read the in) Print to the terminal the patient's name and the bill total (using the function from the file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!