-
Notifications
You must be signed in to change notification settings - Fork 0
/
record.cpp
128 lines (119 loc) · 3.07 KB
/
record.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
#include <iostream>
using namespace std;
// class
class Bank {
private:
int acno;
char name[30];
long balance;
public:
void OpenAccount()
{
cout << "Enter Account Number: ";
cin >> acno;
cout << "Enter Name: ";
cin >> name;
cout << "Enter Balance: ";
cin >> balance;
}
void ShowAccount()
{
cout << "Account Number: " << acno << endl;
cout << "Name: " << name << endl;
cout << "Balance: " << balance << endl;
}
void Deposit()
{
long amt;
cout << "Enter Amount U want to deposit? ";
cin >> amt;
balance = balance + amt;
}
void Withdrawal()
{
long amt;
cout << "Enter Amount U want to withdraw? ";
cin >> amt;
if (amt <= balance)
balance = balance - amt;
else
cout << "Less Balance..." << endl;
}
int Search(int);
};
int Bank::Search(int a)
{
if (acno == a) {
ShowAccount();
return (1);
}
return (0);
}
// main code
int main()
{
Bank C[1000];
int found = 0, a, ch, i,n;
cout<<"Enter the no of accounts ";
cin>>n;
for (i=0; i <n; i++) {
C[i].OpenAccount();
}
do {
// display options
cout << "\n\n1:Display All\n2:By Account No\n3:Deposit\n4:Withdraw\n5:Exit" << endl;
// user input
cout << "Please input your choice: ";
cin >> ch;
switch (ch) {
case 1: // displating account info
for (i = 0; i <n; i++) {
C[i].ShowAccount();
}
break;
case 2: // searching the record
cout << "Account Number? ";
cin >> a;
for (i = 0; i <n; i++) {
found = C[i].Search(a);
if (found)
break;
}
if (!found)
cout << "Record Not Found" << endl;
break;
case 3: // deposit operation
cout << "Account Number To Deposit Amount? ";
cin >> a;
for (i = 0; i <n; i++) {
found = C[i].Search(a);
if (found) {
C[i].Deposit();
break;
}
}
if (!found)
cout << "Record Not Found" << endl;
break;
case 4: // withdraw operation
cout << "Account Number To Withdraw Amount? ";
cin >> a;
for (i = 0; i <n; i++) {
found = C[i].Search(a);
if (found) {
C[i].Withdrawal();
break;
}
}
if (!found)
cout << "Record Not Found" << endl;
break;
case 5: // exit
cout << "Have a nice day" << endl;
break;
default:
cout << "Wrong Option" << endl;
}
} while (ch != 5);
return 0;
}