-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank1.java
More file actions
180 lines (178 loc) · 7.9 KB
/
Bank1.java
File metadata and controls
180 lines (178 loc) · 7.9 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
import java.util.*;
public class Bank1
{
static String name[] = new String[3];
static String accountnum[] = new String[3];
static String id[] = new String[3];
static String password[] = new String[3];
static String lid,lpassword,pname,paccountno;
static int[] amount = new int[3];
static int[] FD = new int[3];
static int choice,pamount;
static boolean loop = true;
static boolean hello = false;
static Scanner sc = new Scanner(System.in);
static Scanner in = new Scanner(System.in);
public static void main(String[] args)
{
System.out.println("Welcome to Bank\n");
do
{
System.out.println("Select 1 for Open Account");
System.out.println("Select 2 for Login");
System.out.println("Select 3 for Account Detail");
System.out.println("Select 4 for Fund Transfer");
System.out.println("Select 5 for Open FD");
System.out.println("Select 6 for Logout");
System.out.println("Select 7 for Exit");
try{
choice = Integer.parseInt(in.next());
}catch(Exception e){
System.out.println("Error 121: Enter valid input.");
continue;
}
switch(choice)
{
case 1:
for(int i=0;i<3;i++)
{
System.out.println("Enter your Name : ");
name[i] = sc.nextLine();
System.out.println("Enter your User Name : ");
id[i] = sc.nextLine();
System.out.println("Enter your Password : ");
password[i] = sc.nextLine();
System.out.println("Enter your Amount : ");
amount[i] = in.nextInt();
accountnum[i]="00"+(i+1);
System.out.println("Your acoount has been created successfully.");
System.out.println("Your Account Number is "+accountnum[i]);
}
break;
case 2:
System.out.println("Enter User Name : ");
lid = sc.nextLine();
System.out.println("Enter Your Password : ");
lpassword = sc.nextLine();
for(int i=0;i<3;i++)
{
if(lid.equals(id[i])&&lpassword.equals(password[i]))
System.out.println("Login Successful.");
}
for(int i=0;i<3;i++)
{
if(!lid.equals(id[i])&&!lpassword.equals(password[i]))
System.out.println("User Name or Password not match.");
break;
}
break;
case 3:
for(int i=0;i<3;i++)
{
if(lid==null&&lpassword==null)
{
System.out.println("Please Login First.");
break;
}
if(lid.equals(id[i])&&lpassword.equals(password[i]))
{
System.out.println("Account Holder Name = "+name[i]);
System.out.println("Account Number = "+accountnum[i]);
System.out.println("User Name = "+id[i]);
System.out.println("Amount = "+amount[i]);
System.out.println("FD Amount = "+FD[i]);
}
}
break;
case 4:
if(lid==null&&lpassword==null)
{
System.out.println("Please Login First.");
break;
}
System.out.println("Enter Receiver Name : ");
pname = sc.nextLine();
System.out.println("Enter Receiver Account No : ");
paccountno = sc.nextLine();
System.out.println("Enter Amount to Transfer : ");
pamount = in.nextInt();
for(int i=0;i<3;i++)
{
if(pname.equals(name[i])&&paccountno.equals(accountnum[i]))
{
for(int j=0;j<3;j++)
{
if(lid.equals(id[j])&&lpassword.equals(password[j]))
{
hello=true;
if(pamount<=amount[j])
{
amount[j] = amount[j]-pamount;
amount[i]=amount[i]+pamount;
System.out.println("Your Transaction Successfully");
System.out.println("Transaction Detail : ");
System.out.println(" Paypee Name : "+pname);
System.out.println(" Paypee Account No : "+paccountno);
System.out.println(" Transferd Amount : "+pamount);
}
else
System.out.println("Transaction fail because your balance is low.");
break;
}
}
}
}
if(!hello)
System.out.println("Paypee account does not exits.");
break;
case 5:
for(int i=0;i<3;i++)
{
if(lid==null&&lpassword==null)
{
System.out.println("Please Login First.");
break;
}
if(lid.equals(id[i])&&lpassword.equals(password[i]))
{
System.out.println("Enter amount for FD : ");
FD[i] = in.nextInt();
if(FD[i]<=amount[i])
{
amount[i] = amount[i]-FD[i];
System.out.println("FD Done Successfully.");
System.out.println("FD price is "+FD[i]);
}
else
System.out.println("Fail!!!!\nFD price is greater then your account balance.");
}
}
break;
case 6:
if(lid==null&&lpassword==null)
{
System.out.println("Please Login First.");
break;
}
lid=null;
lpassword=null;
System.out.println("Logout successfully.");
System.out.println("Do you want to Exit?(y/n)");
String c = sc.nextLine();
if(c.equals("n")||c.equals("n"))
break;
else
{
loop=false;
System.exit(0);
}
case 7:
System.exit(0);
break;
default:
System.out.println("Please Select Number Between 1 to 7.");
break;
}
}while(loop);
}
}