-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSOURCE_CODE.JAVA
More file actions
169 lines (168 loc) · 7.3 KB
/
Copy pathSOURCE_CODE.JAVA
File metadata and controls
169 lines (168 loc) · 7.3 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
import java.util.Scanner;
class BankManagementSystem {
static boolean status = false;
static class Customer {
String name;
String acType;
int deposit;
int ac;
int initial;
int wDraw;
int totalDepo;
int totalWid;
int adminPin;
int custPin;
}
public static void create(Customer cust) {
Scanner scanner = new Scanner(System.in);
System.out.print("\n\t Set Customer Name: ");
cust.name = scanner.nextLine();
System.out.print("\n\t Set Account Number: ");
cust.ac = scanner.nextInt();
scanner.nextLine();
System.out.print("\n\t Enter Account type: ");
cust.acType = scanner.nextLine();
System.out.println("\n\t Account has been created successfully !!!");
}
public static void depo(Customer cust) {
Scanner scanner = new Scanner(System.in);
System.out.print("\t \nEnter the amount you want to deposit : Rs ");
cust.deposit = scanner.nextInt();
System.out.println("\t \nAmount deposited successfully !");
cust.initial += cust.deposit;
cust.totalDepo += cust.deposit;
}
public static void check(Customer cust) {
System.out.println("\t --------------------------------\n");
System.out.println("\t Total available fund: Rs " + cust.initial + "\n");
System.out.println("\t --------------------------------\n");
}
public static void withdraw(Customer cust) {
Scanner scanner = new Scanner(System.in);
System.out.print("\t Enter the withdraw amount: Rs ");
int temp = scanner.nextInt();
if (temp > cust.initial) {
System.out.println("\t ---------------------------------\n");
System.out.println("\t| X--Insuffient Fund Available--X |\n");
System.out.println("\t ---------------------------------\n");
}
else {
cust.wDraw = temp;
cust.initial -= cust.wDraw;
cust.totalWid += cust.wDraw;
}
}
public static void display(Customer cust) {
System.out.println("\n\n\n-------------------------------------------------------------\n");
System.out.println(" \n\n\t\tTRANSACTION DETAILS \n\n");
System.out.println(" \t\t NAME: " + cust.name + "\n");
System.out.println(" \t\t Account Number: " + cust.ac + "\n");
System.out.println(" \t\t Account Type: " + cust.acType + "\n");
System.out.println(" \t\t Recent Deposit: Rs " + cust.deposit + "\n");
System.out.println(" \t\t Recent Withdrawal: RS " + cust.wDraw + "\n");
System.out.println(" \t\t Available Balance: Rs " + cust.initial + "\n");
System.out.println(" \t\t Total Deposite: Rs " + cust.totalDepo + "\n");
System.out.println(" \t\t Total Withdrawal: Rs " + cust.totalWid + "\n");
System.out.println("\n\n\n-------------------------------------------------------------\n");
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Customer cust = new Customer();
cust.adminPin = 1234;
cust.custPin = 123456;
System.out.println("\n\n--------- Welcome to CGU Private Limited Bank ---------\n\n");
int choice;
do {
System.out.println("\nPress Any Key to Continue...");
scanner.nextLine();
System.out.println("\n\n\n===========================================================\n");
System.out.println("\t\t Bank Management System \n\n");
System.out.println("\t \t 1.Create an account with us \n\n");
System.out.println("\t \t 2.Deposit Balance\n\n");
System.out.println("\t \t 3.Check Balance\n\n");
System.out.println("\t \t 4.Withdraw Balance\n\n");
System.out.println("\t \t 5.Account Holder's Details\n\n");
System.out.println("\t \t 6.Exit");
System.out.println("\n===========================================================\n");
System.out.print("\nEnter your choice: ");
choice = scanner.nextInt();
System.out.println("\n\n");
switch (choice) {
case 1:
System.out.print("\nEnter Administrator Pin to Create Account: ");
int tempPin = scanner.nextInt();
if (tempPin == cust.adminPin) {
create(cust);
status = true;
} else {
System.out.println("------- Pin Error -------");
}
break;
case 2:
if(status){
int tempPin2;
System.out.print("\nEnter 6 Digit Pin: ");
tempPin2 = scanner.nextInt();
if (tempPin2 == cust.custPin) {
depo(cust);
} else {
System.out.println("------- Pin Error -------");
}
}else {
System.out.println("------- No Account Found -------");
}
break;
case 3:
if (status) {
int tempPin2;
System.out.print("\nEnter 6 Digit Pin: ");
tempPin2 = scanner.nextInt();
if (tempPin2 == cust.custPin) {
check(cust);
} else {
System.out.println("------- Pin Error -------");
}
} else {
System.out.println("------- No Account Found -------");
}
break;
case 4:
if (status) {
int tempPin2;
System.out.print("\nEnter 6 Digit Pin: ");
tempPin2 = scanner.nextInt();
if (tempPin2 == cust.custPin) {
withdraw(cust);
} else {
System.out.println("------- Pin Error -------");
}
} else {
System.out.println("------- No Account Found -------");
}
break;
case 5:
if (status) {
int tempPin2;
System.out.print("\nEnter 6 Digit Pin: ");
tempPin2 = scanner.nextInt();
if (tempPin2 == cust.custPin) {
display(cust);
} else {
System.out.println("------- Pin Error -------");
}
} else {
System.out.println("------- No Account Found -------");
}
break;
case 6:
break;
}
}
while (choice != 6);
System.out.println("\n\n\n\t ---------------------------------\n");
System.out.println("\t| Thanks For Visiting Here !!! |\n");
System.out.println("\t ---------------------------------\n\n\n\n");
System.out.println("\nPress Any Key To Close Application");
scanner.nextLine();
}
}