非常确定我的问题与花车没有任何关系,我不明白为什么浮子会影响总数>我只是想为我的计算机编程课程为初学者制作一个简单的程序。我正在寻找为什么输入硬币的某些数字并没有输出二十几十五等...一个工作的是50为所有输入还没有找到另一个有效的工作没有错误消息,它只是不打印输出二十,几十,五等等。也许我只是感到非常痛苦,但我似乎无法找到我的程序有什么问题。任何帮助将不胜感激。
quarters = int(input("Enter a number of quarters: "))
dimes = int(input("Enter a number of dimes: "))
nickels = int(input("Enter a number of nickels: "))
pennies = int(input("Enter a number of pennies: "))
total = (quarters * .25) + (dimes * .1) + (nickels * .05) + (pennies * .01)
print("The total value of all coins is: " + str(total))
quarters = 0
nickels = 0
pennies = 0
dimes = 0
twenties = 0
tens = 0
fives = 0
ones = 0
while total > 0:
while total >= 20:
total = total - 20
twenties = twenties + 1
while total >= 10:
total = total - 10
tens = tens + 1
while total >= 5:
total = total - 5
fives = fives + 1
while total >= 1:
total = total - 1
ones = ones + 1
while total >= .25:
total = total - .25
quarters = quarters + 1
while total >= .1:
total = total - .1
dimes = dimes + 1
while total >= .05:
total = total - .05
nickels = nickels + 1
while total >= .01:
total = total - .01
pennies = pennies + 1
print("\nTwenties: " + str(twenties))
print("Tens: " + str(tens))
print("fives: " + str(fives))
print("ones: " + str(ones))
print("quarters: " + str(quarters))
print("dimes: " + str(dimes))
print("nickels: " + str(nickels))
print("pennies: " + str(pennies))
input("\nPress enter to quit")