-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
119 lines (94 loc) · 3.64 KB
/
Account.java
File metadata and controls
119 lines (94 loc) · 3.64 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import java.util.*;
import java.text.DecimalFormat;
public class Account {
Scanner reader = new Scanner(System.in);
DecimalFormat moneyFormat = new DecimalFormat("'$' ###,##0.00");
private int customerNumber;
private int pinNumber;
private double currentBalance = 0;
private double savingBalance = 0;
public int setCustomerNumber(int customerNumber){
this.customerNumber = customerNumber;
return customerNumber;
}
public int getCustomerNumber(){
return customerNumber;
}
public int setPinNumber(int pinNumber){
this.pinNumber = pinNumber;
return pinNumber;
}
public int getPinNumber(){
return pinNumber;
}
public double getCurrentBalance(){
return currentBalance;
}
public double getSavingBalance(){
return savingBalance;
}
public double calCurrentDeposit(double amount){
currentBalance = currentBalance + amount;
return currentBalance;
}
public double calCurrentWithdraw(double amount){
currentBalance = currentBalance - amount;
return currentBalance;
}
public double calSavingWithdraw(double amount){
savingBalance = savingBalance - amount;
return savingBalance;
}
public double calSavingDeposit(double amount){
savingBalance = savingBalance + amount;
return savingBalance;
}
public void getCurrentWithdrawInput(){
System.out.println("Your current Balance : " + moneyFormat.format(currentBalance));
System.out.println("Enter the amount of money you want to withdraw : ");
double amount = reader.nextDouble();
if(currentBalance - amount >= 0){
calCurrentWithdraw(amount);
System.out.println("New Balance : " + moneyFormat.format(currentBalance));
}
else{
System.out.println("\n Sorry! You don't have enough money.\n");
}
}
public void getSavingWithdrawInput(){
System.out.println("Your Saving Balance : " + moneyFormat.format(savingBalance));
System.out.println("Enter the amount of money you want to withdraw : ");
double amount = reader.nextDouble();
if(savingBalance - amount >= 0){
calSavingWithdraw(amount);
System.out.println("New Balance : " + moneyFormat.format(savingBalance));
}
else{
System.out.println("\n Sorry! You don't have enough money.\n");
}
}
public void getCurrentDepositInput(){
System.out.println("Your current Balance : " + moneyFormat.format(currentBalance));
System.out.println("Enter the amount of money you want to deposit : ");
double amount = reader.nextDouble();
if(currentBalance + amount >= 0){
calCurrentDeposit(amount);
System.out.println("Your new Balance is : " + moneyFormat.format(currentBalance));
}
else{
System.out.println("Sorry! Invalid");
}
}
public void getSavingDepositInput(){
System.out.println("Your Saving Balance : " + moneyFormat.format(savingBalance));
System.out.println("Enter the amount of money you want to deposit : ");
double amount = reader.nextDouble();
if(savingBalance + amount >= 0){
calSavingDeposit(amount);
System.out.println("Your new Saving Balance is : " + moneyFormat.format(savingBalance));
}
else{
System.out.println("Sorry! Invalid");
}
}
}