-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank_Management_System.cpp
More file actions
124 lines (114 loc) · 2.69 KB
/
Copy pathBank_Management_System.cpp
File metadata and controls
124 lines (114 loc) · 2.69 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
#include <iostream>
#include <stdio.h>
#include <conio.h>
#define clrscr() system("cls")
using namespace std;
class bank
{
int amount;
public:
bank()
{
amount = 0;
}
void deposit(int amt);
void withdrawal(int amt);
void balance();
};
void bank::deposit(int amt)
{
if (amt < 0)
cout << "Invalid amount\n";
else
amount = amount + amt;
}
void bank::withdrawal(int amt)
{
if (amt < 0)
{
cout << "Invalid amount\n";
}
else if (amt > amount)
{
cout << "Insufficient balance.. please check!\n";
}
else
{
amount = amount - amt;
cout << "Congratulations, Your amount is Successfully withdrawal.\n";
}
}
void bank::balance()
{
cout << "\nYour current balance: " << amount << endl;
}
int main()
{
char ch1, ch2, ch3, ch4;
int count = 4;
// Correct PIN = 1234
while (count != 0)
{
cout << "Enter PIN(4 digit): ";
ch1 = getch();
cout << "*";
ch2 = getch();
cout << "*";
ch3 = getch();
cout << "*";
ch4 = getch();
cout << "*";
if (ch1 == '1' && ch2 == '2' && ch3 == '3' && ch4 == '4')
break;
else
{
count--;
cout << "\nInvalid PIN: only " << count << " options remaining.\n";
}
}
if (count == 0)
{
cout << "\nYour account is block for 24 hours: Please contact in your bank branch...\n";
}
if (ch1 == '1' && ch2 == '2' && ch3 == '3' && ch4 == '4')
{
int choice, myamt;
bank B;
clrscr();
do
{
cout << "\n------------------------Bank Application---------------------------";
cout << "\n1. Diposit";
cout << "\n2. Withdrawal";
cout << "\n3. Check Balance";
cout << "\n4. Exit";
cout << "\n-------------------------------------------------------------------";
cout << "\nEnter Your Choice: ";
cin >> choice;
switch (choice)
{
case 1:
cout << "\nEnter amount for deposit: ";
cin >> myamt;
B.deposit(myamt);
cout << "Congratulations, Your amount is Successfully deposited.\n";
break;
case 2:
cout << "\nEnter amount for withdrawal: ";
cin >> myamt;
B.withdrawal(myamt);
break;
case 3:
B.balance();
break;
default:
break;
}
} while (choice != 4);
}
else
{
cout << "\nWrong pin!";
}
return 0;
}