Question: public class JavaAccount { private String customerName; private long AccountNumber; private double balance; private double interestRate; JavaAccount(String customerName,long AccountNumber,double balance,double interestRate){ this.customerName=customerName; this.AccountNumber=AccountNumber; this.balance=balance; this.interestRate=interestRate;
public class JavaAccount { private String customerName; private long AccountNumber; private double balance; private double interestRate; JavaAccount(String customerName,long AccountNumber,double balance,double interestRate){ this.customerName=customerName; this.AccountNumber=AccountNumber; this.balance=balance; this.interestRate=interestRate; } public String getCustomerName() { return customerName; } public void setCustomerName(String customerName) { this.customerName = customerName; } public long getAccountNumber() { return AccountNumber; } public void setAccountNumber(long accountNumber) { AccountNumber = accountNumber; } public double getBalance() { return balance; } public void setBalance(double d) { this.balance = d; } public double getInterestRate() { return interestRate; } public void setInterestRate(double d) { this.interestRate = d; } public void deposit(double amount){ this.setBalance(this.getBalance()+amount); System.out.println("Deposit Successful"); System.out.println("New Amount:"+this.getBalance()); return; } public void withdraw(double amount){ this.setBalance(this.getBalance()-amount); System.out.println("Withdrawl Successful"); System.out.println("New Amount:"+this.getBalance()); return; } public void checkBalance(){ System.out.println("Balance:"+getBalance()); } }
Create a PremiumAccount.java class.
(a) When you extend the javaAccount.java, you will need to override the super() constructors.
(b) Add a static field called "minimumBalanceRequired" such that when account balance meets the minimumBalanceRequired, you get unlimited checking without fees. Otherwise, regular checking fees will apply. // hint: inside the withdraw() method, deduct a fee whenever the balance is below the minimum.
(c) Add a static method to reset minimumBalanceRequired.
(d) Add a new data fields called PIN# such that an internal PIN# has to match the input parameters before any transactions. Re-write the following methods with a PIN#: checkBalance(); deposit(), withdraw() and so on.
(e) Add an implementation of the .toString() method to override any default methods: The toString() methods returns the premium account information
#2. Add implementation of exception handling to the PremiumAccount.java class.
(a) Inside each method with a PIN# input parameter, throw a appropriate exception object of your choice.
(b) (OPTIONAL) Implement a new exception mechanism that allows only 3 consecutive trials of invalid PINs.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
