-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6.cpp
192 lines (178 loc) · 4.35 KB
/
6.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
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
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
#define MAX 3
int c = 0;
char an[15];
class bank
{
char acc[15];
long balance;
float rate;
public:
bank()
{
cout << "\nEnter " << c + 1 << " Account Details :- \n";
cout << "\nEnter Account Number : ";
cin >> acc;
cout << "Enter Account Balance : ";
cin >> balance;
cout << "Enter Interest Rate : ";
cin >> rate;
cout << "\n";
c++;
}
~bank()
{
c--;
}
void deposit()
{
long add;
cout << "\nEnter Amount : ";
cin >> add;
balance = balance + add;
cout << "\nYour Updated Balance is : " << balance << "\n\n";
}
int withdraw()
{
long sub;
cout << "Enter Amount : ";
cin >> sub;
if (sub > balance)
{
cout << "\nInsufficient Balance !\nYour Total Balance is : " << balance;
}
else
{
}
balance = balance - sub;
cout << "\nYour updated balance is : " << balance << "\n\n";
return 1;
return 0;
}
void interest()
{
double ti;
ti = (float)(balance * rate / 100);
cout << "\nYour Total Interest is : Rs. " << ti << "\n\n";
}
void display()
{
cout << "\nAccount Number :- " << acc;
cout << "\nTotal Balance : Rs. " << balance;
cout << "\nInterest Rate :- " << rate << "\n\n";
}
int search()
{
if (strcmp(acc, an) == 0)
{
return 1;
}
else
{
return 0;
}
}
};
int main()
{
int i, flag, choice;
bank b[MAX];
while (choice != 5)
{
cout <<"\n ENTER YOUR CHOICE \n\n 1. Deposit\n 2. Withdraw\n 3. Calculate Interest\n 4. Account Information\n 5. Exit\n\n ";
cin >> choice;
switch (choice)
{
case 1:
cout << "\n\n------DEPOSIT \n";
cout << "\nEnter Account Number : ";
cin >> an;
for (i = 0; i < c; i++)
{
flag = b[i].search();
if (flag == 1)
{
b[i].deposit();
cout << "\nAMOUNT DEPOSITED SUCCESSFULLY.";
break;
}
}
if (flag == 0)
{
cout << "\nAccount Number " << an << " NOT FOUND !\n\n";
}
getch();
break;
case 2:
cout << "\n------WITHDRAW \n";
cout << "\nEnter Account Number : ";
cin >> an;
for (i = 0; i < c; i++)
{
flag = b[i].search();
if (flag == 1)
{
int a = b[i].withdraw();
if (a == 1)
cout << "\nAMOUNTWITHDRAWNSUCCESSFULLY.\n";
break;
}
}
if (flag == 0)
{
cout << "\nAccount Number " << an << " NOT FOUND !\n\n";
}
getch();
break;
case 3:
cout << "\n------CALCULATE INTEREST \n";
cout << "\nEnter Account Number : ";
cin >> an;
for (i = 0; i < c; i++)
{
flag = b[i].search();
if (flag == 1)
{
b[i].interest();
break;
}
}
if (flag == 0)
{
cout << "\nAccount Number " << an << " NOT FOUND !\n\n";
}
getch();
break;
case 4:
cout << "\n------ACCOUNT INFORMATION \n";
cout << "\nEnter Account Number : ";
cin >> an;
for (i = 0; i < c; i++)
{
flag = b[i].search();
if (flag == 1)
{
b[i].display();
break;
}
}
if (flag == 0)
{
cout << "Account Number " << an << " NOT FOUND !\n\n";
}
getch();
break;
case 5:
exit(0);
break;
default:
cout << "\nINVALID INPUT !\n";
getch();
}
}
return 0;
}