Skip to main content
  1. Posts/

The Atm Machine Problem

·299 words·2 mins
Table of Contents

The Atm Machine Problem: #

Hello, recently i’ve been given a problem called the ar machine so basically the problem was that a person wanted to withdraw $150 and to do that you would need 1 x $100 and 1 x $50 right but what if you want’d to withdraw $152 you can’t do tha so the program would come out with a error message.

So first we had to make a input to captures the person’s input. Then we had to use def(to create your own function ) called bill_despenser(amount) after that we had to use if-else the condition was that if the amount’s remainder was not equal zero it would return 0, 0, 0, 0, 0 meaning the bottom code would not execute however if the condition was false it would ignore the top code and execute the bottom.

The final step is to add the dialogue so if the if condition is true it would say something like “sorry we cannot withdraw that amount” and if the condition was false it would say “thank you for stopping bye”

atm = int(input("Withdraw the amount of money you want: $ "))
def bill_despenser(amount):
    # if the amount is not able to be divided by five 
    if amount % 5 != 0:
        print("<<<sorry we can't withdraw that amount>>>".upper())
        print("<<Error Error>>>".upper())
        return [0, 0, 0, 0, 0]
    
    bills = [100, 50, 20, 10, 5]
    output = []

    for note in bills:
        money_count = amount // note
        output.append(money_count)
    
        # the remainder
        amount = amount % note

    return output

amount = atm
print(f"<<You entered ${amount} Here is your bill: {bill_despenser(amount)}>>") 
print("Thank you for stopping by at my_atm :)".upper())

Thank you :3 dont mind how long it took for me to come back :33333333 #kodert #the amazing python programer not the amazing grammer. Byeeeeeee.