-
Notifications
You must be signed in to change notification settings - Fork 0
/
Account.java
176 lines (150 loc) · 5.89 KB
/
Account.java
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.supriya;
import java.text.DecimalFormat;
import java.util.*;
public class Account{
Scanner input = new Scanner(System.in);
DecimalFormat moneyFormat = new DecimalFormat("'$'###,##0.00");
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 getCheckingBalance() {
return checkingBalance;
}
public double getSavingBalance() {
return savingBalance;
}
public double calcCheckingWithdraw(double amount) {
checkingBalance = (checkingBalance - amount);
return checkingBalance;
}
public double calcSavingWithdraw(double amount) {
savingBalance = (savingBalance - amount);
return savingBalance;
}public double calcCheckingDeposit(double amount) {
checkingBalance = (checkingBalance + amount);
return checkingBalance;
}
public double calcSavingDeposit(double amount) {
savingBalance = (savingBalance + amount);
return savingBalance;
}
public void getCheckingWithdrawInput() {
System.out.println("Checking Account Balance: " + moneyFormat.format(checkingBalance));
System.out.print("Amount you want to withdraw from Checking Account: ");
double amount = input.nextDouble();
if ((checkingBalance - amount) >= 0) {
double res=checkingBalance - amount;
calcCheckingWithdraw(amount);
System.out.println("New Checking Account Balance: " + moneyFormat.format(checkingBalance));
if(true){
System.out.println("Do you want to take receipt?");
System.out.println("Type 1: YES");
System.out.println("Type 2: NO");
int a = input.nextInt();
switch(a){
case 1:
new Swing(res,"CheckingAccount:WithDraw");
break;
default:
System.out.println("THANK YOU FOR USING ATM");
break;
}
}
} else {
System.out.println("Balance Cannot be Negative." + "\n");
}
}
public void getsavingWithdrawInput() {
System.out.println("Saving Account Balance: " + moneyFormat.format(savingBalance));
System.out.print("Amount you want to withdraw from saving Account: ");
double amount = input.nextDouble();
if ((savingBalance - amount) >= 0) {
double res=savingBalance-amount;
calcSavingWithdraw(amount);
System.out.println("New saving Account Balance: " + moneyFormat.format(savingBalance));
if(true){
System.out.println("Do you want to take receipt?");
System.out.println("Type 1: YES");
System.out.println("Type 2: NO");
int a = input.nextInt();
switch(a){
case 1:
new Swing(res,"SavingAccount:WithDraw");
break;
default:
System.out.println("THANK YOU FOR USING ATM");
break;
}
}
} else {
System.out.println("Balance Cannot be Negative." + "\n");
}
}
public void getCheckingDepositInput() {
System.out.println("Checking Account Balance: " + moneyFormat.format(checkingBalance));
System.out.print("Amount you want to Deposit from Checking Account: ");
double amount = input.nextDouble();
if ((checkingBalance + amount) >= 0) {
double res=checkingBalance+amount;
calcCheckingDeposit(amount);
System.out.println("New Checking Account Balance: " + moneyFormat.format(checkingBalance));
if(true){
System.out.println("Do you want to take receipt?");
System.out.println("Type 1: YES");
System.out.println("Type 2: NO");
int a = input.nextInt();
switch(a){
case 1:
new Swing(res,"CheckingAccount:Deposit");
break;
default:
System.out.println("THANK YOU FOR USING ATM");
break;
}
}
} else {
System.out.println("Balance Cannot be Negative." + "\n");
}
}
public void getSavingDepositInput() {
System.out.println("Saving Account Balance: " + moneyFormat.format(savingBalance));
System.out.print("Amount you want to Deposit from saving Account: ");
double amount = input.nextDouble();
if ((savingBalance + amount) >= 0) {
double res=savingBalance+amount;
calcSavingDeposit(amount);
System.out.println("New saving Account Balance: " + moneyFormat.format(savingBalance));
if(true){
System.out.println("Do you want to take receipt?");
System.out.println("Type 1: YES");
System.out.println("Type 2: NO");
int a = input.nextInt();
switch(a){
case 1:
new Swing(res,"SavingAccount:Deposit");
break;
default:
System.out.println("THANK YOU FOR USING ATM");
break;
}
}
} else {
System.out.println("Balance Cannot be Negative." + "\n");
}
}
private int customerNumber;
private int pinNumber;
private double checkingBalance = 0;
private double savingBalance = 0;
}