Computer Science, asked by saadullahsaleem1, 1 year ago

4.a. Write down a Python code for shopping cash register in which a shop keeper must give a change to the customer with respect to the total shopping amount. Assume total shopping amount of a customer is 37 Rs and he gave a 50 Rs note to the shop keeper. Your code must tell the shop keeper the amount of 100 Rs, 50 Rs, 20 Rs, 10 Rs, 5 Rs, 2 Rs or 1 Rs note/coins that he must return to the customer, in case of 37 Rs of shopping and 50 Rs note, a customer must get one 10 Rs note, one 5 Rs coin and one 2 Rs coin. Accept user defined input for both shopping amount and the note given to the shop keeper.

Answers

Answered by Anonymous
0

Answer:

total_cost,f_available,o_available = int(input('Total:')),int(input('5 coins available')),int(input('1 coins available'))

f_coins_needed = total_cost//5

left = total_cost - (5*f_coins_needed)

o_coins_needed = left // 1

if o_coins_needed <= o_available and f_coins_needed <= f_available:

   print('rs.1 coins needed :%d' %(o_coins_needed), 'rs.5 coins needed: %d' %(f_coins_needed))

else:

   print('-1')

Similar questions