So I am new to python and am writing this for an assignment, For example if I run 101 as the input, it will run correctly and display that a I need "1 $100 Bill and 1 $1 Bill" but if I run that I need $125 back, it will execute as "1 $100 Bill and 1 $20 Bill" but not execute the remaining $5 bill. I also realized that I cannot run anything under 100 either but that I can fix. I am trying to understand the If/else statements
#
# Python ATM machine
#
import math
withdrawl = int(input("how much money do you want to withdrawl (max withdrawl is $200): "))
if (withdrawl > 200):
print("You are trying to withdraw too much money, this machine is kind of sucky, have a great day!!")
else:
print("1 100 Dollar Bill")
remainder1 = withdrawl - 100
if ((remainder1 / 20) >= 1):
print (math.trunc(remainder1/20)," 20 Dollar Bills")
else:
print("0 20 Dollar Bills")
remainder2 = remainder1 - (math.trunc(remainder1/20)*20)
if ((remainder2 / 10) >= 1):
print (math.trunc(remainder2/10)," 10 dollar Bills")
else:
print ("0 10 Dollar Bills")
remainder3 = remainder2 - (math.trunc(remainder2/10)*10)
if ((remainder3 / 5) >= 1):
print (math.trunc(remainder3 / 5)," 5 dollar Bills")
else:
print("0 5 dollar bills")
remainder4 = remainder3 - (math.trunc(remainder3/5)*5)
if ((remainder4 / 1) >= 1):
print (math.trunc(remainder3/1)," 1 dollar Bills")
else:
print("Thank you for using our ATM machine")
print ("Thank you for using our ATM machine")
remainder1,remainder2, etc. in the watch list, you'll probably be able to figure out the problem yourself ... and you'll have prepared yourself up for a future situation where the program is too long to post on StackOverflow.if/elsestatement is stopping the program if desired condition is met. You need to rebuild this code.