this is a simple program where I am getting input as change owed in $, and I have to return the total amount of coins. My program runs correctly until it comes down to counting pennies. Can someone see, Why does it give negative output, even when I told the program with an if statement not to run after it comes to 0.
import sys
import cs50
val = cs50.get_float(("Change owed: "))
count = 0
newVal = val
while newVal > .25:
newVal = round(newVal - 0.25, 2)
print(newVal)
count +=1
if newVal == 0.25:
newVal = round(newVal - 0.25, 2)
print(newVal)
count +=1
elif newVal < 0.25:
newVal = round(newVal - 0.10, 2)
print(newVal)
count +=1
if newVal < 0.10:
newVal = round(newVal - 0.05, 2)
print(newVal)
count +=1
if newVal < 0.05:
newVal = round(newVal - 0.01, 2)
print(newVal)
count +=1
if newVal < 0:
break
print(count)