In: Computer Science
1. This programming assignment will involve the idea of modern-day banking using an automated teller machine (ATM). The server-side software maintains a bank account and a user accesses the account via client software. For this program, you can assume that a single account will be accessed by a single user. This avoids synchronization problems with multiple users. There must be two sides to this program: a server and a client. The server maintains the balance and does all updates (withdrawals and deposits) and also responds to queries on the amount of money in the account. The user issues commands via the client to check the available balance, withdraw money from the account, and deposit money into the account. The client does none of the calculations but only sends requests to the server that executes the commands and returns the answer to the client. The server should initialize the balance in the bank account to $100.
2. The user must be able to do the following activities from the client software:
• Deposit money into the account on the server.
• Withdraw money from the account on the server.
• Check the balance of the amount in the account on the server.
3. Instructions
• The programs MUST be written in the programming language ***Python 3***.
Code for above program :-
# function for ATM machine features
def ATM(balance):
print("Select a option:")
print("d : deposit money")
print("w : withdraw money")
print("c : check balance")
print("q : quit")
# Asking user for the desired operation
option = input("Enter your choice: ")
# Checking for deposit operation
if option =="d":
# amount to be deposited
amount = float(input("Enter amount to deposit: "))
# updating balance
balance = balance + amount
# displaying updated balnce
print("Your account balance is : ${}".format(balance))
# again calling ATM function
ATM(balance)
# withdrawal operation
elif option=="w":
# amount to be withdrawed
amount = float(input("Enter amount to withdraw: "))
# amount to be withdrawl greater than balance
if amount> balance:
print("You dont have enough balance to withdraw:")
# displaying updated balnce
print("Your account balance is : ${}".format(balance))
# again calling ATM function
ATM(balance)
# if amount under balance
else:
# updated balance
balance = balance - amount
print("${} withdrawl from your account".format(amount))
# displaying updated balnce
print("Your account balance is : ${}".format(balance))
# again calling ATM function
ATM(balance)
# check balance operation
elif option == 'c':
# displaying balnce
print("Your account balance is : ${}".format(balance))
# again calling ATM function
ATM(balance)
# quiting from server
elif option == 'q':
return balance
# check for invalid input
else:
print("Invalid Input")
ATM(balance)
return balance
# initialising account balance to $100
balance = 100
# calling main function
balance = ATM(balance)
Screenshot For above code :-