Python assignment Game ATM machine Use the Account class cre
Python assignment: (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.00. 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.
Here is account class that I had created:
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():
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())
main()
Solution
public class account {
public static void main(String[] args) {
int id = 1122;
double balance = 20000;
double annualinterestrate = 0.045;
hereaccount account = new hereaccount(id, balance, annualinterestrate);
account.withdraw(2500);
account.deposit(3000);
account.dateCreated();
account.monthlyinterestrate(annualinterestrate);
}
}
import java.util.*;
public class hereaccount {
private int id;
private double balance;
private double annualinterestrate;
private Date date;
public hereaccount() {
id = 0;
balance = 0;
annualinterestrate = 0;
}
public hereaccount(int id, double balance, double annualinterestrate) {
this.id = id;
this.balance = balance;
this.annualinterestrate = annualinterestrate;
date = new Date();
}
public double getbalance() {
return balance;
}
public Date dateCreated(){
System.out.println(\"Date created: \" + date);
return date;
}
public int id() {
return id;
}
public double annualinterestrate() {
return annualinterestrate;
}
public void deposit(double amount) {
balance = balance + amount;
System.out.println(\"Your current balance is now: \" + balance);
}
public void withdraw(double amount) {
balance = balance - amount;
System.out.println(\"Your current balance is now: \" + balance);
}
public void setID(int newID) {
id = newID;
}
public double monthlyinterestrate(double interest){
interest = annualinterestrate/12;
System.out.println(\"The monthly interest rate is: \" + interest);
return interest;
}
}


