Question: import java.text.DecimalFormat; import java.util.Scanner; import java.util.Scanner; public class ATM { public void menu(Account acct) { Scanner input=new Scanner(System.in); int option=6; DecimalFormat df2 = new DecimalFormat(#.##);


import java.text.DecimalFormat; import java.util.Scanner;
import java.util.Scanner;
public class ATM {
public void menu(Account acct) { Scanner input=new Scanner(System.in); int option=6; DecimalFormat df2 = new DecimalFormat("#.##"); while(option!=4) { System.out.println("Main Menu"); System.out.println("1. Your Account"); System.out.println("2. Withdraw Option"); System.out.println("3. Deposit Option"); System.out.println("4. Exit System"); System.out.println("Choose an Option: "); option=input.nextInt(); if(option==1) { System.out.println("Customer Info: "+acct.getCustName()); System.out.println("Account Balance : $"+df2.format(acct.getBalance())); System.out.println("Monthly Interest Earned: $"+df2.format(acct.monthlyInterest())); continue; } else if(option==2) { System.out.println("Please enter your withdrawl total"); double amount=input.nextDouble(); acct.withdraw(amount); continue; }
else if(option==3) { System.out.println("Please enter deposit total"); double amount=input.nextDouble(); acct.deposit(amount); continue; } else if(option==4) { return; } } input.close();
}
public static void main(String[] args) {
ATM atm=new ATM(); Account a1=new Account(101,"Eric"); Account a2=new Account(102,"Erica"); a1.setBalance(50); a2.setBalance(1000); a1.setAnnIntRate(5); a2.setAnnIntRate(5); Scanner data=new Scanner(System.in); int id; boolean valid=true; while(valid) {
System.out.println("Please enter your ID: "); id=data.nextInt(); if(id==a1.getId()) { atm.menu(a1); continue; } else if(id==a2.getId()) { atm.menu(a2); continue; } else { System.out.println("The customer ID does not work"); continue; } } data.close();
}
}
//////////////////////////////////////////////////////////////////////////
public class Account { private double balance; private double annIntRate; private String custName; private int id;
public Account(int id,String name) { this.id=id; custName=name; }
public String getCustName() { return custName; } public void setCustName(String custName) { this.custName = custName; } public int getId() { return id; } public void setId(int id) { this.id = id; } public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } public double getAnnIntRate() { return annIntRate; } public void setAnnIntRate(double annIntRate) { this.annIntRate = annIntRate; } public void deposit(double amount) { balance+=amount; } public double monthlyInterest() { return (getBalance()*(annIntRate/12/100)); } public void withdraw(double amount) { if(amount
}
Automated Teller Machine (ATM) (15 marks / 3%) In this assignment you'll be implementing an application that will extend the Simple ATM you developed for assignment1. Part A Create two sub-classes of the Account class, ChequingAccount and SavingsAccount with the following specifications 1. Chequing Account - The chequing account has an overdraft limit of 500$ - Annual interest rate of maximum 1%. 2. Savings account - Cannot be overdrawn - Annual interest rate of minimum 3% - For every dollar deposited the bank automatically deposits half a dollar (e.g. the account is setup such that an employer/parent automatically contributes as well) Part 2 Add a new option to the main menu of the application to allow the user to create an account 1. The main menu of the application shall have the following options: a. Create Account (shows the account creation menu) b. Account Info (works as before) c. Withdraw (works as before) d. Deposit (works as before) c. Exit (exits the application) 2. The Account creation feature shall allow the user to specify: a. Account ID - shall be verified to be valid (non-negative integer) and not conflicting with an existing account ID b. Initial Balance c. Annual Interest Rate d. Type of account: chequing or savings. Based on the type selected by the user create either a ChequingAccount or a Savings Account Notes We will assume that you can have maximum 10 accounts in this application. For full marks do not use the keyword 'static' except for the main method declaration and for constant (final) fields. You'll need to create an object of the ATM class in the main method so you can call the menu method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
