Repository navigation
Expand file tree
/
Copy pathATM_Interface.java
More file actions
248 lines (248 loc) · 12.7 KB
/
Copy pathATM_Interface.java
File metadata and controls
248 lines (248 loc) · 12.7 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import java.util.*;
public class ATM_Interface {
static int counter=0;
static double balance;
static String user_name;
static long account_number;
static String account_name;
static double deposit_money;
static double withdraw_money;
static double transfer_money;
static void display_balance(String name_user,String name_account,long number_account,double balance)
{
System.out.println("***************");
System.out.println("BALANCE DETAILS");
System.out.println("_______________");
System.out.println("User Name : " + name_user);
System.out.println("Account Holder Name : " + name_account);
System.out.println("Account Number : " + number_account);
System.out.println("ACCOUNT BALANCE : " + balance);
}
static void deposit_display(String name_user,String name_account,long number_account)
{
System.out.println("***********************");
System.out.println("Welcome to DEPOSIT Menu");
System.out.println("_______________________");
System.out.println("User Name : " + name_user);
System.out.println("Account Holder Name : " + name_account);
System.out.println("Account Number : " + number_account);
}
static double deposit_final(double money_deposit,double balance_deposit)
{
balance_deposit=balance_deposit+money_deposit;
return balance_deposit;
}
static void withdraw_display(String name_user,String name_account,long number_account)
{
System.out.println("***********************");
System.out.println("Welcome to WITHDRAW Menu");
System.out.println("_______________________");
System.out.println("User Name : " + name_user);
System.out.println("Account Holder Name : " + name_account);
System.out.println("Account Number : " + number_account);
}
static double withdraw_final(double money_withdraw,double balance_withdraw)
{
balance_withdraw=balance_withdraw-money_withdraw;
return balance_withdraw;
}
static void transfer_display(String name_user,String name_account,long number_account)
{
System.out.println("***********************");
System.out.println("Welcome to TRANSFER Menu");
System.out.println("_______________________");
System.out.println("User Name : " + name_user);
System.out.println("Account Holder Name : " + name_account);
System.out.println("Account Number : " + number_account);
}
static double transfer_final(double money_transfer,double balance_transfer)
{
balance_transfer=balance_transfer-money_transfer;
return balance_transfer;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int check=0;
int pin=1234; //Initializing the PIN
int enter_pin;
String recipent_name;
long recipent_account;
long recipent_account_again;
String recipent_ifsc;
System.out.println("OASIS BANK WELCOMES YOU");
System.out.println("Enter LOGIN CREDENTIALS to LOGIN = ");
System.out.println("___________________________________");
System.out.println("Enter User ID = ");
user_name=sc.nextLine();
System.out.println("Enter Account Holder Name = ");
account_name=sc.nextLine();
System.out.println("Enter Account Number = ");
account_number=sc.nextLong();
int i=0;
while(i<3)
{
System.out.println("Enter PIN = ");
enter_pin=sc.nextInt();
if(pin!=enter_pin)
{
System.out.println("Wrong pin\n");
if(i<=1)
{
System.out.println("Please Try Again!!!");
}
System.out.println((i+1)+" Invalid attempt");
System.out.println((3-(i+1))+" Attempts left\n");
i++;
continue;
}
else
{
System.out.println("LOGIN SUCCESSFULL");
System.out.println("_________________");
System.out.println("*****************");
System.out.println("Enter Balance Amount = ");
balance=sc.nextDouble();
while(true)
{
System.out.println("\nWELCOME to the OASIS BANK");
System.out.println("_________________________");
System.out.println("_________________________");
System.out.println("BANKING CREDIANTILS for this Session");
System.out.println("____________________________________");
System.out.println("User Name : " + user_name);
System.out.println("Account Holder Name : " + account_name);
System.out.println("Account Number : " + account_number);
while(true)
{
System.out.println("******************");
System.out.println("*****ATM MENU*****");
System.out.println("******************");
System.out.println("Press '0' to check the Total Number of Transactions done till now in this Session");
System.out.println("Press '1' to check BALANCE");
System.out.println("Press '2' to DEPOSIT");
System.out.println("Press '3' to WITHDRAW.");
System.out.println("Press '4' to TRANSFER");
System.out.println("Press '5' to EXIT & LOG OUT");
int input;
System.out.println("ENTER your Choice to perform the respective BANKING Function = ");
input=sc.nextInt();
switch(input)
{
case 0:
if(counter==0)
{
System.out.println("No Transactions History for this Session");
}
else
{
System.out.println("Total Transactions found for this Session = "+counter);
}
break;
case 1:
display_balance(user_name,account_name,account_number,balance);
break;
case 2:
deposit_display(user_name,account_name,account_number);
System.out.println("Enter the Deposit Amount = ");
deposit_money=sc.nextDouble();
System.out.println("Press '1' to Confirm Deposit or Press '0' to Cancel Deposit");
check=sc.nextInt();
if(check==1)
{
balance=deposit_final(deposit_money,balance);
System.out.println("Deposit Successfull");
counter++;
}
else
{
System.out.println("Deposit Cancelled");
}
break;
case 3:
withdraw_display(user_name,account_name,account_number);
System.out.println("Enter the Withdraw Amount = ");
withdraw_money=sc.nextDouble();
System.out.println("Press '1' to Confirm Withdraw or Press '0' to Cancel Withdraw");
check=sc.nextInt();
if(check==1)
{
if(withdraw_money<=balance)
{
balance=withdraw_final(withdraw_money,balance);
System.out.println("Withdraw Successfull");
counter++;
}
else
{
System.out.println("Insufficient Balance to Withdraw");
}
}
else
{
System.out.println("Withdraw Cancelled");
}
break;
case 4:
transfer_display(user_name,account_name,account_number);
sc.nextLine();
System.out.print("\nEnter the Recipent's NAME : ");
recipent_name=sc.nextLine();
System.out.print("\nEnter the Recipent BANK ACCOUNT NUMBER = ");
recipent_account=sc.nextLong();
System.out.print("\nEnter the Recipent's BANK ACCOUNT NUMBER again to CONFIRM = ");
recipent_account_again=sc.nextLong();
sc.nextLine();
System.out.print("\nEnter the Recipent BANK IFSC CODE = ");
recipent_ifsc=sc.nextLine();
System.out.println("Enter the Transfer Amount = ");
transfer_money=sc.nextDouble();
if(recipent_account==recipent_account_again)
{
System.out.println("Press '1' to Confirm Transaction or Press '0' to Cancel Transaction");
check=sc.nextInt();
if(check==1)
{
if(transfer_money<=balance)
{
balance=transfer_final(transfer_money,balance);
System.out.println("Money = " + transfer_money + " successfully transferred to :\nRECIPENT Details : ");
System.out.println("Recipent NAME = "+recipent_name);
System.out.println("Recipent BANK ACCOUNT NUMBER = "+recipent_account);
System.out.println("Recipent BANK IFSC CODE = "+recipent_ifsc);
counter++;
}
else
{
System.out.println("Insufficient Balance to Transfer");
}
}
else
{
System.out.println("Transaction Cancelled");
}
}
else
{
System.out.println("Recipent's Account Number does not Matched\nPlease Check it & Try Again later...");
}
break;
case 5:
System.out.println("LOGGED OUT Successfull");
System.out.println("THANK YOU FOR BANKING WITH US!!!\nSEE YOU AGAIN NEXT TIME");
return;
default:
System.out.println("Invalid Input!!!\nPlease Try again...");
break;
}
}
}
}
}
if(i>=3)
{
System.out.println("No More Chances Left\nAccount has been Temporarily Blocked due to 3 Unsuccesfull Attempts");
System.out.println("Please try again after sometime...");
}
sc.close();
}
}