-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.java
More file actions
137 lines (108 loc) · 3.92 KB
/
MainMenu.java
File metadata and controls
137 lines (108 loc) · 3.92 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
import java.util.*;
import java.text.DecimalFormat;
import java.io.IOException;
public class MainMenu extends Account {
Scanner reader = new Scanner(System.in);
DecimalFormat moneyFormat = new DecimalFormat("'$' ###,##0.00");
HashMap<Integer, Integer> data = new HashMap<Integer, Integer>();
public void getLogin() throws IOException {
int l = 1;
do {
try {
data.put(832688, 190283);
data.put(217532, 583326);
data.put(928366, 811049);
data.put(925070, 456966);
data.put(841237, 459001);
data.put(123456, 589741);
System.out.println("Welcome to BIT ATM");
System.out.println("Please Enter your Customer Number : ");
setCustomerNumber(reader.nextInt());
System.out.println("Enter your PIN NUmber : ");
setPinNumber(reader.nextInt());
} catch (Exception e) {
System.out.println("\n" + "Invalid Characters" + "\n");
e.printStackTrace();
l = 2;
}
int cust_no = getCustomerNumber();
int pin_no = getPinNumber();
if (data.containsKey(cust_no) && data.get(cust_no) == pin_no) {
getAccountType();
} else {
System.out.println("\n Wrong Customer Number or PIN Number \n");
}
} while (l == 1);
}
public void getAccountType() {
System.out.println("Please Enter the account you want to access : ");
System.out.println("Press 1 - Your Current Account");
System.out.println("Press 2 - Saving Account");
System.out.println("Press 3 - Exit");
int key = reader.nextInt();
switch (key) {
case 1:
getCurrent();
break;
case 2:
getSaving();
break;
case 3:
System.out.println("GoodBye! Thank you for using BIT ATM.");
break;
default:
System.out.println("Invalid choice");
getAccountType();
}
}
public void getCurrent() {
System.out.println("You Current Account");
System.out.println("Press 1 : view balance");
System.out.println("Press 2 : withdraw money");
System.out.println("Press 3 : deposit money");
System.out.println("Choice: ");
int key = reader.nextInt();
switch (key) {
case 1:
System.out.println("You current Balance : " + moneyFormat.format(getCurrentBalance()));
getAccountType();
break;
case 2:
getCurrentWithdrawInput();
getAccountType();
break;
case 3:
getCurrentDepositInput();
getAccountType();
break;
}
}
public void getSaving() {
System.out.println("You Current Account");
System.out.println("Press 1 : view balance");
System.out.println("Press 2 : withdraw money");
System.out.println("Press 3 : deposit money");
System.out.println("Choice: ");
int key = reader.nextInt();
switch (key) {
case 1:
System.out.println("Saving Account Balance : " + moneyFormat.format(getSavingBalance()));
getAccountType();
break;
case 2:
getSavingWithdrawInput();
getAccountType();
break;
case 3:
getSavingDepositInput();
getAccountType();
break;
case 4:
System.out.println("Goodbye! Thanks for using the ATM.");
break;
default:
System.out.println("\n Invalid Choices \n");
getCurrent();
}
}
}