Denominations - 2
The possible denominations of currency notes are 100, 50, 20 and 10. The amount A to be withdrawn is given as input. Write a program to break the amount into minimum number of bank notes.
Input
The first line of input is an integer A.
Output
The output should be a string representing number of 100, 50, 20, 10 notes possible.
In the given example amount
370, it can be written as370 = 3*(100) + 1*(50) + 1*(20) + 0*(10)Then the output should be
100 Notes: 3
50 Notes: 1
20 Notes: 1
10 Notes: 0
Sample Input 1
370
Sample Output 1
100 Notes: 3
50 Notes: 1
20 Notes: 1
10 Notes: 0
Sample Input 2
130
Sample Output 2
100 Notes: 1
50 Notes: 0
20 Notes: 1
10 Notes: 1
sum=input()
count_ten=0
count_twenty=0
count_fifty=0
count_hundred=0
if len(sum)>3:
count_hundred = int(sum[0:-2])
elif len(sum)==2:
count_hundred = 0
else:
count_hundred = int(sum[0])
number = int(sum[-2:])
while number>0:
if number-50 >= 0:
number -= 50
count_fifty += 1
continue
if number-20 >= 0:
number -= 20
count_twenty += 1
continue
if number-10 >= 0:
number -= 10
count_ten += 1
continue
print(f"100 Notes: {count_hundred}\n50 Notes: {count_fifty}\n20 Notes: {count_twenty}\n10 Notes: {count_ten}\n")
Comments
Leave a comment