-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionMenu.java
More file actions
164 lines (115 loc) · 4.2 KB
/
OptionMenu.java
File metadata and controls
164 lines (115 loc) · 4.2 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
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
package AtmMachineProject;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Scanner;
public class OptionMenu extends Account{
Scanner menuInput = new Scanner(System.in);
DecimalFormat moneyFormat = new DecimalFormat(" '$', ###, ##0.00");
HashMap<Integer,Integer> data = new HashMap<Integer, Integer>();
public void getLogin() throws IOException{
int x=1;
do{
try {
data.put(98400,7840);
data.put(98401, 7830);
System.out.println("Welcome Atm Machine Projent");
System.out.println("Enter your Account Number");
setCustomerNumber(menuInput.nextInt());
System.out.println("Enter tha pin Number");
setPinNumber(menuInput.nextInt());
}catch(Exception e){
System.out.println("\n"+ "Invalid Character(s)"+ "\n");
x=2;
break;
}
int cn = getCustomerNumber();
int cp = getPinNumber();
if(data.containsKey(cn) && data.get(cn) == cp) {
getAccountType();
}else {
System.out.println("\n" + "Wrong Custumer Number Or Pin Number"+ "\n");
}
}while(x==2);
}
public void getAccountType() {
System.out.println("Select tha Account you Want to Access: ");
System.out.println(" Type 1 - Checking Account");
System.out.println(" Type 2 - Saving Account");
System.out.println(" Type 3 - Exit");
System.out.print("Choice :");
int selection = menuInput.nextInt();
switch(selection) {
case 1:
getCheckingAccount();
break;
case 2:
getSavingAccount();
break;
case 3:
System.out.println("Thank You for Using this ATM, bye." + "\n");
break;
default:
System.out.println("\n"+ "Invalide Choice"+ "\n");
break;
}
}
public void getSavingAccount() {
System.out.println("Saving Acount: ");
System.out.println(" Type 1 - Veiw Balance");
System.out.println(" Type 2 - Deposit Funds");
System.out.println(" Type 3 - Credit Funds");
System.out.println(" Type 4 - Exit");
System.out.print("Choice: ");
int selection = menuInput.nextInt();
switch(selection) {
case 1:
System.out.println("Saving Account Balance: "+ moneyFormat.format(getSavingBalance()));
getAccountType();
break;
case 2:
getSavingCreditInput();
getAccountType();
break;
case 3:
getSavingDepositInput();
getAccountType();
break;
case 4:
System.out.println("Thank You for Using this ATM, bye." + "\n");
break;
default:
System.out.println("\n"+ "Invalide Choice"+ "\n");
getSavingAccount();
}
}
public void getCheckingAccount() {
System.out.println("Checking Acount: ");
System.out.println(" Type 1 - Veiw Balance");
System.out.println(" Type 2 - Deposit Funds");
System.out.println(" Type 3 - Credit Funds");
System.out.println(" Type 4 - Exit");
System.out.print("Choice: ");
int selection = menuInput.nextInt();
switch(selection) {
case 1:
System.out.println("Checking Account Balance: "+ moneyFormat.format(getCheakBalance()));
getAccountType();
break;
case 2:
getCheckingCreditInput();
getAccountType();
break;
case 3:
getCheckingDepositInput();
getAccountType();
break;
case 4:
System.out.println("Thank You for Using this ATM, bye." + "\n");
break;
default:
System.out.println("\n"+ "Invalide Choice"+ "\n");
getCheckingAccount();
}
}
}