advictoriam Mar 5th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- An account that earns interest at a fixed rate.
- public class SavingsAccount extends BankAccount
- private double interestRate;
- Constructs a bank account with a given interest rate.
- @balance initialBalance the initial balance
- @param rate the interest rate
- public SavingsAccount(double initialBalance, double rate)
- interestRate = rate;
- Adds the earned interest to the account balance.
- public void addInterest()
- double interest = getBalance() * interestRate / 100;
- // This method checks your work. Do not modify it.
- public static double check(double initialBalance, double rate)
- SavingsAccount account = new SavingsAccount(initialBalance, rate);
- return account.getBalance();
RAW Paste Data