-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingsAccount.java
More file actions
36 lines (30 loc) · 1.05 KB
/
SavingsAccount.java
File metadata and controls
36 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package unit09.mySolutions;
import unit09.solutions.BankAccount;
//Creates a savings account type of bank account
public class SavingsAccount extends BankAccount {
private double interestRate = 0.0;
public SavingsAccount(String name, double balance, double rate) {
super(name, balance);
interestRate = rate;
}
public SavingsAccount(String name, double rate) {
super(name);
interestRate = rate;
}
public SavingsAccount(String name) {
// Calls SavingsAccount constructor using default interest rate of 0
this(name, 0.0);
}
// Posts monthly interest by multiplying current balance by
// current interest rate divided by 12 and then adding
// result to balance by making deposit
public void postInterest() {
deposit(getBalance() * (interestRate / 12));
}
// Prints bank statement including customer name and current balance
// and prints interest rate
public void printStatement() {
super.printStatement();
System.out.println(interestRate + "% current rate of interest\n");
}
}