-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
49 lines (39 loc) · 1.07 KB
/
Copy pathBankAccount.java
File metadata and controls
49 lines (39 loc) · 1.07 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
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.example.Bank;
public class BankAccount {
private String name;
private int money;
private double interest;
public BankAccount(String name, int money, double interest){
this.name = name;
this.money = money;
this.interest = interest;
}
public BankAccount(String name, double interest){
this.name = name;
this.interest = interest;
}
public void deposit(int n){
money += n;
}
public void withdraw(int n){
money -= n;
}
public void addInterest(){
money += money / 100 * interest;
}
public String toString(){
System.out.println(money);
return money + "";
}
public static void main(String[]args){
BankAccount a = new BankAccount("Cooper", 200, 5);
BankAccount b = new BankAccount("Condy", -5);
a.deposit(200);
a.withdraw(100);
b.deposit(500);
b.withdraw(100);
b.addInterest();
a.toString();
b.toString();
}
}