-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankApplication.cs
More file actions
203 lines (157 loc) · 5.2 KB
/
BankApplication.cs
File metadata and controls
203 lines (157 loc) · 5.2 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
using System;
using System.Collections.Generic;
public class Bank
{
public Dictionary<int, string> map = new Dictionary<int, string>();
public Dictionary<int, int> map1 = new Dictionary<int, int>();
public int avlAmount = 0;
public static void Main()
{
Bank b = new Bank();
while (true)
{
Console.WriteLine("1. Create Account\n2. Deposit Amount\n3. Withdraw Amount\n4. Transfer Amount\n5. Transaction History\n6. Logout\n");
Console.WriteLine("Enter option : ");
int n = Convert.ToInt32(Console.ReadLine());
int acNum = 0;
if (n == 1)
{
b.CreateAccount();
}
else if (n == 2)
{
b.DepositAmount();
}
else if (n == 3)
{
b.WithdrawAmount();
}
else if (n == 4)
{
b.TransferAmount();
}
else if (n == 5)
{
b.TransactionHistory();
}
else
{
Console.WriteLine("Please Enter a valid option");
}
if (n == 6)
{
b.Logout();
break;
}
}
}
public void CreateAccount()
{
Console.WriteLine("Please Enter the Account number : ");
int acNum = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please Enter your name : ");
string acName = Console.ReadLine();
if (map.ContainsKey(acNum))
{
Console.WriteLine("Please Enter differnt possible number");
}
map.Add(acNum, acName);
map1.Add(acNum, avlAmount);
}
public void DepositAmount()
{
Console.WriteLine("Please Enter your Account Number :");
int acNum = Convert.ToInt32(Console.ReadLine());
if (map1.ContainsKey(acNum))
{
Console.WriteLine("Please Enter your deposit amount : ");
int deposit = Convert.ToInt32(Console.ReadLine());
avlAmount += deposit;
map1[acNum] = avlAmount;
Console.WriteLine("Your current Balance : " + avlAmount);
}
else
{
Console.WriteLine("Please Enter Vaild Account Number! ");
}
}
public void WithdrawAmount()
{
Console.WriteLine("Please Enter your Account Number :");
int acNum = Convert.ToInt32(Console.ReadLine());
if (map.ContainsKey(acNum))
{
Console.WriteLine("Please Enter your Withdraw amount : ");
int withdraw = Convert.ToInt32(Console.ReadLine());
if (avlAmount >= withdraw)
{
avlAmount -= withdraw;
map1[acNum] = avlAmount;
}
else
{
Console.WriteLine("Your Account Does not have sufficient Balance to Withdraw ");
}
Console.WriteLine("Your current Balance : " + avlAmount);
}
else
{
Console.WriteLine("Please Enter Vaild Account Number! ");
}
}
public void TransferAmount()
{
Console.WriteLine("Please Enter your Account Number :");
int acNum = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please Enter your Account Number to transfer Money:");
int acNum1 = Convert.ToInt32(Console.ReadLine());
if (map1.ContainsKey(acNum) && map1.ContainsKey(acNum1))
{
Console.WriteLine("Please Enter amount to be transfered : ");
int transfer = Convert.ToInt32(Console.ReadLine());
int t1 = transfer;
if (avlAmount >= transfer)
{
avlAmount -= transfer;
map1[acNum] = avlAmount;
Console.WriteLine("Your current Balance : " + avlAmount);
}
else
{
Console.WriteLine("Your Account Does not have sufficient Balance to transfer ");
}
if (map1.ContainsKey(acNum1))
{
map1[acNum1] += t1;
}
else
{
Console.WriteLine("Please enter valid account number to transfer ");
}
}
else
{
Console.WriteLine("Please Enter Vaild Account Number! ");
}
}
public void TransactionHistory()
{
Console.WriteLine("Please Enter your Account Number :");
int acNum = Convert.ToInt32(Console.ReadLine());
if (map1.ContainsKey(acNum))
{
foreach (KeyValuePair<int, int> ele1 in map1)
{
if (ele1.Key == acNum)
{
Console.WriteLine("Your Available Account Balance : " + ele1.Value);
}
}
}
}
public void Logout()
{
Console.WriteLine("Thank you for using our application 😀 \n Have a great day!! 🎉");
}
}