Question: PYTHON v3 (Game: ATM machine) Use the Account class created in Exercise 7.3 to simulate an ATM machine. Create ten accounts in a list with
PYTHON v3
(Game: ATM machine) Use the Account class created in Exercise 7.3 to simulate an ATM machine. Create ten accounts in a list with the ids 0 , 1 , ..., 9 , and an initial balance of $100. The system prompts the user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an id is accepted, the main menu is displayed as shown in the sample run. You can enter a choice of 1 for viewing the current balance, 2 for withdrawing money, 3 for depositing money, and 4 for exiting the main menu. Once you exit, the system will prompt for an id again. So, once the system starts, it wont stop.(Game: ATM machine) Use the Account class created in Exercise 7.3 to simulate an ATM machine. Create ten accounts in a list with the ids 0 , 1 , ..., 9 , and an initial balance of $100. The system prompts the user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an id is accepted, the main menu is displayed as shown in the sample run. You can enter a choice of 1 for viewing the current balance, 2 for withdrawing money, 3 for depositing money, and 4 for exiting the main menu. Once you exit, the system will prompt for an id again. So, once the system starts, it wont stop.
class Account: # Construct an Account object def __init__(self, id, balance = 100, annualInterestRate = 0): self.__id = id self.__balance = balance self.__annualInterestRate = annualInterestRate
def getId(self): return self.__id
def getBalance(self): return self.__balance
def getAnnualInterestRate(self): return self.__annualInterestRate
def getMonthlyInterestRate(self): return self.__annualInterestRate / 12
def setPreviousPrice(self, previousPrice): self.previousPrice = previousPrice
def setCurrentPrice(self, currentPrice): self.currentPrice = currentPrice
def withdraw(self, amount): self.__balance -= amount
def deposit(self, amount): self.__balance += amount
def getMonthlyInterest(self): return self.__balance * self.getMonthlyInterestRate()
def main(): # Create an account with width 4 and height 40 account = Account(1122, 20000, 4.5) account.withdraw(2500) account.deposit(3000) print("ID is", account.getId()) print("Balance is", account.getBalance()) print("Monthly interest rate is", account.getMonthlyInterestRate()) print("Monthly interest is", account.getMonthlyInterest()) main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
