Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

new to python help with it i am using python 3, if you can add a screenshot it w

ID: 3717594 • Letter: N

Question

new to python help with it i am using python 3, if you can add a screenshot it would help alot

12.3 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 ini- tial 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 won't stop

Explanation / Answer

Hi, Please find my implementaton.

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():
   # Creating ten accounts in a list with the ids 0 , 1 , ..., 9 , and an initial balance of $100
  
   # List of accounts
   accounts = [];
  
   # Creating ten accounts
   for i in range(0, 10):
       account = Account(i, 100.0);
       accounts.append(account);
      
   # Playing Game ATM   
   while True:
  
       # Reading id from user
       id = int(input(" Enter account id: "));
      
       # Loop till id is valid
       while id < 0 or id > 9:
           id = int(input(" Invalid Id.. Re-enter: "));

       # Iterating over game  
       while True:
          
           # Printing menu
           print(" 1 - View Balance 2 - Withdraw 3 - Deposit 4 - Exit ");
          
           # Reading selection
           selection = int(input(" Enter your selection: "));
          
           # Getting account object
           for acc in accounts:
               # Comparing account id
               if acc.getId() == id:
                   accountObj = acc;
                   break;
          
           # View Balance
           if selection == 1:
               # Printing balance
               print(accountObj.getBalance());
              
           # Withdraw  
           elif selection == 2:
               # Reading amount
               amt = float(input(" Enter amount to withdraw: "));
               # Calling withdraw method
               accountObj.withdraw(amt);
               # Printing updated balance
               print(" Updated Balance: " + str(accountObj.getBalance()) + " ");
              
           # Deposit  
           elif selection == 3:
               # Reading amount
               amt = float(input(" Enter amount to deposit: "));
               # Calling deposit method
               accountObj.deposit(amt);
               # Printing updated balance
               print(" Updated Balance: " + str(accountObj.getBalance()) + " ");
          
           # Any other choice
           else:
               break;
          
# Main function          
main()