
Andrew K.
asked 12/18/20Write a python program that calculates the following...
A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one liter of milk is $0.38, and the profit of each carton of milk is $0.27. Write a program that does the following:
Prompts the user to enter the total amount of milk (in liters) produced in the morning.
Outputs the number of milk cartons needed to hold milk. (Round your answer to the nearest integer).
Outputs the cost of producing milk.
Outputs the profit for producing milk.
Please use float for all values and round to two decimal places.
A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one liter of milk is $0.38, and the profit of each carton of milk is $0.27. Write a program that does the following:
Prompts the user to enter the total amount of milk (in liters) produced in the morning.
Outputs the number of milk cartons needed to hold milk. (Round your answer to the nearest integer).
Outputs the cost of producing milk.
Outputs the profit for producing milk.
Please use float for all values and round to two decimal places.
1 Expert Answer

Patrick B. answered 12/20/20
Math and computer tutor/teacher
# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
print("Hello world")
import math
num_liters = input("Please input the # of liters produced :>")
num_cartons = math.ceil( float(num_liters)/3.78)
profit = round(int(num_cartons) * 0.27,2)
cost = round(int(num_cartons) * 0.38,2)
print(" # of liters = " + str(num_liters))
print(" # of cartons = " + str(num_cartons))
formatted_float = "{:.2f}".format(float(profit))
print(" profit = " + str(formatted_float))
formatted_float = "{:.2f}".format(float(cost))
print(" cost = " + str(formatted_float))
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
source code uploaded to RESOURCES section under this link12/20/20