-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountNew.java
More file actions
64 lines (30 loc) · 977 Bytes
/
AccountNew.java
File metadata and controls
64 lines (30 loc) · 977 Bytes
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public class AccountNew{
public static void main(String[] args){
private double balance;
private double deposit;
private double withdraw;
public double getBalance(){
return balance;
}
public void setBalance(double balance){
this.balance = balance;
}
public double withdraw(double withdrawalAmount){
if (withdrawalAmount > balance){
System.out.println("Withdrawal amount exceeded account balance.");
}else{
balance = balance - withdrawalAmount;
}
if (withdrawalAmount < 0){
System.out.println("Withdrawal amount cannot be equal to or less than 0");
} else{
balance = balance - withdrawalAmount;
}
public double deposit(double depositAmount){
if (depositAmount < 0){
System.out.println("deposit amount cannot be less than 0");
}else{
balance = balance + depositAmount;
}
}
}