In: Computer Science
In python:
In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one particular jurisdiction, drink containers holding one liter or less have a 0.10???????,??????????????????ℎ???????????ℎ??????????ℎ????0.10deposit,anddrinkcontainersholdingmorethanoneliterhavea0.25 deposit. Write a program that reads the number of containers of each size from the user as variables. Your program should continue by computing and displaying the refund that will be received for returning those containers.
#Python program that prompts user to enter two types of container bottles
#Then find the total deposit of each type of container and add to total deposit variable.
#Then print the total deposit of containers on display output.
def main():
#Set values for less than and more than one litre
LESS_THAN_ONE_LITRE=0.10
MORE_THAN_ONE_LITRE = 0.25
#set total_deposit to 0
total_deposit=0
#continue reading input from user
while True:
#read number of containers of type1 of less than 1 litre
type1=int(input('Enter number of containsers less than 1 litre : '))
# read number of containers of type2 of less than 1 litre
type2 = int(input('Enter number of containsers more than 1 litre : '))
#check if type1 is more than 0
if type1 >0:
#add amount to total_deposit
total_deposit=total_deposit+type1*LESS_THAN_ONE_LITRE
# check if type1 is more than 0
if type2>0:
# add amount to total_deposit
total_deposit = total_deposit + type2 * MORE_THAN_ONE_LITRE
#print total_deposit on display
print('Depsit amount :$ {0:.2f}'.format(total_deposit))
#calling main method to start the program
main()
-------------------------------------------------------------------------------------
Sample Output:
Enter number of containsers less than 1 litre : 1
Enter number of containsers more than 1 litre : 1
Depsit amount :$ 0.35
Enter number of containsers less than 1 litre : 2
Enter number of containsers more than 1 litre : 2
Depsit amount :$ 1.05