-
Notifications
You must be signed in to change notification settings - Fork 0
/
banksecurity2.cpp
152 lines (144 loc) · 5.02 KB
/
banksecurity2.cpp
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
#include<iostream>
#include<fstream>
#include<sstream>
using namespace std;
int main()
{
int a, i = 0;
string name, pin, age, user, word, word1, old, pin1, pin2;
string cred[2], bp[2];
cout << " BANK SECURITY SYSTEM" << endl;
cout << "_+_+_+_+_+_+_+_+_+_+_+_+_" << endl << endl;
cout << "+ 1.Register +" << endl;
cout << "+ 2.Login +" << endl;
cout << "+ 3.Change PIN +" << endl;
cout << "+ 4.Exit +" << endl;
cout << "+_+_+_+_+_+_+_+_+_+_+_+_+" << endl << endl;
do {
cout << endl << endl;
cout << "enter option:- ";
cin >> a;
switch (a)
{
case 1: {
cout << "_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+" << endl << endl;
cout << "|~~~~~~~~~~~~~~Register~~~~~~~~~~~~~~|" << endl;
cout << "enter Full Name:-";
cin >> name;
cout << "Create Pin:-\n";
cin >> pin;
cout << "Enter Age:-\n";
cin >> age;
ofstream of1;
of1.open("locker.txt");
if (of1.is_open()) {
of1 << name << "\n";
of1 << pin << "\n";
of1 << age << "\n";
cout << "Registered" << endl;
}
else {
cout << "Error opening file" << endl;
}
break;
}
case 2: {
i = 0;
cout << "_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+" << endl << endl;
cout << "+~~~~~~~~~~~~~~~Login~~~~~~~~~~~~~~~~+" << endl;
cout << "_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+" << endl << endl;
ifstream of2;
of2.open("locker.txt");
cout << "enter Full Name:- ";
cin >> user;
cout << "enter PIN: - ";
cin >> pin;
if (of2.is_open()) {
while (!of2.eof()) {
string text;
while (getline(of2, text)) {
istringstream iss(text);
iss >> word;
cred[i] = word;
i++;
}
if (user == cred[0] && pin == cred[1]) {
cout << "~~~~Successful Login~~~~";
cout << endl << endl;
cout << " DETAILS: " << endl;
cout << "Username: " + name << endl;
cout << "PIN: " + pin << endl<<endl;
cout << "Age: " + age << endl;
}
else {
cout << endl << endl;
cout << "INCORRECT DETAILS" << endl;
cout << "~~ 1.Press 2 to Login ~~" << endl;
cout << "~~ 1.Press 3 to Change PIN ~~" << endl;
break;
}
}
}
else {
cout << "Error opening file" << endl;
}
break;
}
case 3: {
i = 0;
cout << "~~~~~~~~~Change PIN~~~~~~~~" << endl;
ifstream of0;
of0.open("locker.txt");
cout << "Enter old PIN:- ";
cin >> old;
if (of0.is_open()) {
string text;
while (getline(of0, text)) {
istringstream iss(text);
iss >> word1;
bp[i] = word1;
i++;
}
if (old == bp[1]) {
of0.close();
ofstream of1;
of1.open("locker.txt");
if (of1.is_open()) {
cout << "Enter new PIN:- ";
cin >> pin1;
cout << "Enter PIN again:- ";
cin >> pin2;
if (pin1 == pin2) {
of1 << bp[0] << "\n";
of1 << pin1;
cout << "PIN Changed successfully" << endl;
}
else {
of1 << bp[0] << "\n";
of1 << old;
cout << "PIN not matched" << endl;
}
}
else {
cout << "Error opening file" << endl;
}
}
else {
cout << "Enter valid PIN" << endl;
}
}
else {
cout << "Error opening file" << endl;
}
break;
}
case 4: {
cout << "Thank You for Using Banking Services";
break;
}
default:
cout << "Choose a Valid Option";
}
} while (a != 4);
return 0;
}