Question: JAVA Create a static method in the SavingsAccount and CurrentAccount classes called displayNumberOfAccounts() . This method should show the number of accounts created of that
JAVA
Create a static method in the SavingsAccount and CurrentAccount classes called displayNumberOfAccounts(). This method should show the number of accounts created of that particular sub class.
public class CurrentAccount extends Account { private double overdraftLimit;
public CurrentAccount(int accountNumber, double overdraftLimit) { super(accountNumber); this.overdraftLimit = overdraftLimit; }
public void withdraw(double amount) { if (amount > 0) if ((balance + overdraftLimit) - amount >= 0) balance -= amount; else System.err.println("Account.withdraw(...): " + "cannot withdraw more than your balance."); else System.err.println("Account.withdraw(...): " + "cannot withdraw negative amount."); }
}
public class SavingAccount extends Account { private double interestRate;
public SavingAccount(int accountNumber, double interestRate) { super(accountNumber); this.interestRate = interestRate; }
public void display() { super.display(); System.out.println("Interest rate: " + interestRate); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
