-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFeature.java
More file actions
195 lines (184 loc) · 6.36 KB
/
Feature.java
File metadata and controls
195 lines (184 loc) · 6.36 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
package Project;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;
public class Feature {
static Scanner sc = new Scanner(System.in);
static void checkBal(Stack<Double> bal, double d,int a) {
System.out.println("*Check balance*");
System.out.println(bal.peek());
d=(double) bal.peek();
}
static void fundTrans(Stack<Double> history,double d,int a, Stack<Double> bal) {
System.out.println("*Fund Transfer*");
System.out.println("1. Withdraw");
System.out.println("2. Deposit");
System.out.println("3. Transfer to another account");
System.out.println("Enter your choice :");
int ch3 = sc.nextInt();
switch(ch3)
{
case 1:
System.out.println("*Withdraw*");
System.out.println("Enter the amount");
double w = sc.nextInt();
history.add(-w);
if(w<d)
{
d=d-w;
bal.push(d);
// System.out.println("New Balance : " + InitialBalance);
}
else
{
System.out.println("Insuffient Balance\n Money cannot be withdrawn");
}
break;
case 2:
System.out.println("*Deposit*");
System.out.println("Enter the amount");
double de = sc.nextInt();
history.add(+de);
d=d+de;
bal.push(d);
// System.out.println("New Balance : " + InitialBalance);
break;
case 3:
System.out.println("*Transfer to another account*");
System.out.println("Enter sender account number : ");
System.out.println("Enter receiver account number : ");
break;
}
}
static void transHistory(Stack<Double> history, @SuppressWarnings("rawtypes") ArrayList<Stack> History, int a) {
System.out.println("*Transaction History*");
for(int i=0;i<=History.size();i++) {
if(i==a) {
History.add(history);
}
}
Project.features.display(history);
}
static void Loan(Stack<Double> bal) {
System.out.println("Loan");
//System.out.println("Enter account number");
AskAccount.whichacc();
System.out.println("Enter the Loan Amount : ");
int loanamt= sc.nextInt();
double min=0.3*bal.peek();
if(loanamt>min||loanamt<bal.peek())
{
System.out.println("You are Eligible for the Loan.");
System.out.println("Now Submit your documents (True/False)");
boolean doc = sc.nextBoolean();
if(doc==true)
{
System.out.println("Your loan is granted.\nThe amount will be added to your account");
bal.push(loanamt+bal.peek());
}
else
{
System.out.println("Submit your documents");
}
}
else
{
System.out.println("You are not Eligible for the Loan.");
}
}
@SuppressWarnings("unchecked")
static void BankDetails() {
System.out.println("");
for(int in=0;in<Project.features.ll.size();in++){
System.out.println("Account "+(in+1));
String crn = (String) Project.features.ll.get(in).peek();
Project.features.ll.get(in).pop();
String Acc = (String) Project.features.ll.get(in).peek();
Project.features.ll.get(in).pop();
String ifsc = (String) Project.features.ll.get(in).peek();
Project.features.ll.get(in).pop();
String Bankname = (String) Project.features.ll.get(in).peek();
System.out.println("Bank Name : "+Bankname);
Project.features.ll.get(in).push(Bankname);
System.out.println("IFSC code : "+ifsc);
Project.features.ll.get(in).push(ifsc);
System.out.println("Account no: "+Acc);
Project.features.ll.get(in).push(Acc);
System.out.println("CRN no : "+crn);
Project.features.ll.get(in).push(crn);
}
}
static void changeAcc (int Mpin) {
System.out.println("**Account Change to**");
int chg = sc.nextInt();
for(int in=0;in<=Project.features.ll.size();in++) {
if(in==(chg-1)){
Project.features.ll.get(chg-1);
System.out.print("Using Account "+chg);
main(chg,Mpin);
}
}
}
static double dec(int a) {
double[] Balance = new double[Project.features.ll.size()];
Balance = new double[]{5000,2000,1000,3000};
return Balance[a];
}
public static void main(int n,int Mpin) {
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
int a= n-1;
Stack<Double> bal = new Stack<Double>();
Stack<Double> history = new Stack<Double>();
@SuppressWarnings("rawtypes")
ArrayList <Stack> History = new ArrayList<Stack>();
bal.add((double) dec(a));
int cho;
do
{
System.out.println("\n**Home Page**");
System.out.println("1.Check balance");
System.out.println("2.Fund Transfer");
System.out.println("3.Transaction History");
System.out.println("4.Loan\n5.Check Bank details");
System.out.println("6.Switch Account");
System.out.println("0.Exit\n");
System.out.println("Enter your Choice");
cho=sc.nextInt();
switch(cho){
case 0:
System.out.println("Thank you");
System.exit(0);
break;
case 1:
checkBal(bal, dec(a), a);
break;
case 2:
System.out.println("Enter your MPIN");
int mpin = sc.nextInt();
if(mpin == Mpin ) {
fundTrans(history, dec(a), a, bal);
}
else {
System.out.print("Invalid Pin...!!!\n");
}
break;
case 3:
transHistory(history,History,a);
break;
case 4:
Loan(bal);
break;
case 5:
BankDetails();
break;
case 6:
changeAcc(Mpin);
break;
default:
System.out.println("Invalid input!!");
break;
}
}while(cho!=0);
}
}