Jun-24-2019, 01:20 PM
Write a program that reads an input representing a change which is an amount less than 1 dollar. The program calculates the change into 50, 10, 5 and 1 cent coins. The program then displays the number of each coin required for that change. E.g.
Enter change: 47
50 cent: 0
10 cent: 4
5 cent: 1
1 cent: 2
Enter change: 47
50 cent: 0
10 cent: 4
5 cent: 1
1 cent: 2
def main(): print("This program calculates the change") amount = int(input("Enter the amount: ")) half = amount // 50 print("50 cent: ", half) dimes = amount // 10 print("10 cent: ", dimes) nickels = amount // 5 print("5 cent: ", nickels) pennies = amount // 1 print("1 cent: ", pennies)The output is way different from expected. Need some guidance on writing the correct calculations, thanks.
Output:Enter the amount: 47
50 cent: 0
10 cent: 4
5 cent: 9
1 cent: 47