FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-programming/OOP2_Lab6/Source.cpp at main · Exzqqq/cpp-programming · GitHub
Exzqqq
/
cpp-programming
Public
forked from
Rustam-Z/cpp-programming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-programming
/
OOP2_Lab6
/
Source.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
335 lines (305 loc) · 7.51 KB
Breadcrumbs
cpp-programming
/
OOP2_Lab6
/
Source.cpp
Copy path
File metadata and controls
335 lines (305 loc) · 7.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#
include
<
iostream
>
#
include
<
string
>
#
include
<
conio.h
>
//
for _getch() function
using
namespace
std
;
//
balance = balance * pow((1 + (ROI / 100)), year);
//
Functions
void
F_First_Program
();
//
showing first program in main
void
F_Second_Program
();
//
showing second program in main
//
For the first program
class
Publication
{
//
base class for classes 'Book' and 'Tape'
private:
string title;
float
price;
public:
void
getdata
() {
cout <<
"
Book title:
"
;
cin >> title;
cout <<
"
Price 'USA $':
"
;
cin >> price;
}
void
showdata
() {
cout <<
"
Book title: '
"
<< title <<
"
'
"
<< endl;
cout <<
"
Price:
"
<< price <<
"
$
"
<< endl;
}
};
class
Book
:
public
Publication
{
//
derived class from Publication
private:
int
page_count;
public:
void
getdata
() {
Publication::getdata
();
//
getdata() of class Publicaton
cout <<
"
Number of pages:
"
;
cin >> page_count;
}
void
showdata
() {
Publication::showdata
();
//
showdata() of class Publication
cout <<
"
Number of pages:
"
<< page_count << endl;
}
};
class
Tape
:
public
Publication
{
//
derived class from Publication
private:
float
playing_time;
public:
void
getdata
() {
Publication::getdata
();
cout <<
"
Playing time of audiobook:
"
;
cin >> playing_time;
}
void
showdata
() {
Publication::showdata
();
cout <<
"
Playing time of audionbook:
"
<< playing_time << endl;
}
};
//
For the second program
class
ACCOUNT
{
private:
//
customer name, account number and type of account.
string name;
string account_number;
string type_account;
public:
void
getdata
() {
cout <<
"
Name:
"
;
cin >> name;
cout <<
"
Account Number:
"
;
cin >> account_number;
cout <<
"
Type of Account:
"
;
cin >> type_account;
}
void
showdata
() {
cout <<
"
Name:
"
<< name << endl;
cout <<
"
Account Number:
"
<< account_number << endl;
cout <<
"
Type of Account:
"
<< type_account << endl;
}
};
class
CURR_ACCT
:
public
ACCOUNT
{
private:
int
amount;
int
penalty =
2
;
int
balance =
0
;
int
withdraw;
public:
void
Deposit
() {
cout <<
"
Enter your deposit balance:
"
;
cin >> amount;
if
(amount >=
100
) {
balance = balance + amount;
cout <<
"
Successfully added!
\n\n
"
;
}
else
{
cout <<
"
Deposit cannot be less than 100$
\n\n
"
;
system
(
"
pause
"
);
system
(
"
cls
"
);
Deposit
();
}
}
void
Balance
() {
ACCOUNT::showdata
();
cout <<
"
Balance:
"
<< balance << endl << endl;
}
void
Withdraw
() {
cout <<
"
Enter the balance you want to withdraw:
"
;
cin >> withdraw;
}
void
Penalty
() {
if
(balance - withdraw >
100
) {
balance = balance - withdraw;
cout <<
"
Successfully done!
\n\n
"
;
}
else
if
(balance - withdraw <
0
) {
cout <<
"
You do not have such balance of money in your account!
\n
"
;
cout <<
"
Your balance is
"
<< balance << endl;
system
(
"
pause
"
);
system
(
"
cls
"
);
Withdraw
();
}
else
{
cout <<
"
Your account balance is less than 100$.
\n
You got penalty -2$.
\n\n
"
;
balance = balance - withdraw - penalty;
}
}
};
class
SAV_ACCT
:
public
ACCOUNT
{
private:
int
amount;
int
balance =
0
;
int
withdraw;
float
year;
public:
void
Deposit
() {
cout <<
"
Enter your deposit balance:
"
;
cin >> amount;
balance = balance + amount;
}
void
Balance
() {
ACCOUNT::showdata
();
cout <<
"
Balance:
"
<< balance << endl << endl;
}
void
Withdraw
() {
cout <<
"
Enter the balance you want to withdraw:
"
;
cin >> withdraw;
if
(balance - withdraw >
100
) {
balance = balance - withdraw;
cout <<
"
Successfully done!
\n\n
"
;
}
else
if
(balance - withdraw <
0
) {
cout <<
"
You do not have such balance of money in your account!
\n
"
;
cout <<
"
Your balance is
"
<< balance << endl;
system
(
"
pause
"
);
system
(
"
cls
"
);
Withdraw
();
}
}
void
Compute_Interest
() {
Balance
();
cout <<
"
ROI (Return on Investment) = 4%
\n
"
;
cout <<
"
Enter the year of investment:
"
;
cin >> year;
cout <<
"
Your balance after
"
<< year <<
"
year(s) will be
"
<< balance *
pow
(
1.04
, year) <<
"
\n\n
"
;
}
};
int
main
() {
for
(
int
k =
0
; k <
1000
; k++) {
system
(
"
cls
"
);
cout <<
"
\n\t\t
1. First program (Books)
\n\t\t
2. Second program (Bank account)
\n\t\t
0. Exit
\n\n\t
Your choice:
"
;
switch
(
_getch
())
{
//
case '1' for the first program
case
'
1
'
:
F_First_Program
();
break
;
//
case '2' for the second program
case
'
2
'
:
F_Second_Program
();
break
;
//
case '0' to exit
case
'
0
'
:
k =
1000
;
break
;
default
:
cout <<
"
\t
Your choice is not available in Menu.
\n\t
Please try one more time.
\n
"
;
break
;
}
}
cout << endl;
system
(
"
pause
"
);
return
0
;
}
//
For outputing programs
void
F_First_Program
() {
system
(
"
cls
"
);
Book book;
Tape tape;
for
(
int
j =
0
; j <
1000
; j++) {
system
(
"
cls
"
);
cout <<
"
Welcome to Bookshop 'AliBooks'
\n
1. Paper version
\n
2. Audiobook
\n
0. Go back
\n
Your choice:
"
;
switch
(
_getch
())
{
//
case 1 for the first program
case
'
1
'
:
system
(
"
cls
"
);
book.
getdata
();
cout <<
"
\n\n
Your given info:
\n
"
;
book.
showdata
();
system
(
"
pause
"
);
break
;
//
case 2 for the second program
case
'
2
'
:
system
(
"
cls
"
);
tape.
getdata
();
cout <<
"
\n\n
Your given info:
\n
"
;
tape.
showdata
();
system
(
"
pause
"
);
break
;
//
case 0 to exit
case
'
0
'
:
j =
1000
;
break
;
default
:
cout <<
"
\t
Your choice is not available in Menu.
\n\t
Please try one more time.
\n
"
;
break
;
}
//
switch
}
//
for loop
}
void
F_Second_Program
() {
system
(
"
cls
"
);
CURR_ACCT
account1;
SAV_ACCT
account2;
for
(
int
i =
0
; i <
1000
; i++) {
system
(
"
cls
"
);
cout <<
"
\t
WELCOME TO 'AliBank'
\n
Chooce your account rate:
\n
1. Current account
\n
2. Saving account
\n
0. Go back
\n
Your choice:
"
;
switch
(
_getch
())
{
//
current account
case
'
1
'
:
system
(
"
cls
"
);
account1.
getdata
();
//
calling the function from base class
for
(
int
l =
0
; l <
1000
; l++) {
system
(
"
cls
"
);
cout <<
"
1. Deposit
\n
2. Display the balance
\n
3. Withdraw money
\n
0. Go back
\n
Your choice:
"
;
switch
(
_getch
())
{
//
case 1 for the first program
case
'
1
'
:
system
(
"
cls
"
);
account1.
Deposit
();
system
(
"
pause
"
);
break
;
//
case 2 for the second program
case
'
2
'
:
system
(
"
cls
"
);
account1.
Balance
();
system
(
"
pause
"
);
break
;
case
'
3
'
:
system
(
"
cls
"
);
account1.
Withdraw
();
account1.
Penalty
();
system
(
"
pause
"
);
break
;
case
'
0
'
:
l =
1000
;
F_Second_Program
();
break
;
default
:
cout <<
"
\t
Your choice is not available in Menu.
\n\t
Please try one more time.
\n
"
;
break
;
}
//
switch
}
//
for loop
//
saving account
case
'
2
'
:
system
(
"
cls
"
);
account2.
getdata
();
//
calling the function from base class
for
(
int
j =
0
; j <
1000
; j++) {
system
(
"
cls
"
);
cout <<
"
1. Deposit
\n
2. Display the balance
\n
3. Withdraw money
\n
4. Compute Interest
\n
0. Go back
\n
Your choice:
"
;
switch
(
_getch
())
{
case
'
1
'
:
system
(
"
cls
"
);
account2.
Deposit
();
system
(
"
pause
"
);
break
;
case
'
2
'
:
system
(
"
cls
"
);
account2.
Balance
();
system
(
"
pause
"
);
break
;
case
'
3
'
:
system
(
"
cls
"
);
account2.
Withdraw
();
system
(
"
pause
"
);
break
;
case
'
4
'
:
system
(
"
cls
"
);
account2.
Compute_Interest
();
system
(
"
pause
"
);
break
;
case
'
0
'
:
j =
1000
;
F_Second_Program
();
break
;
default
:
cout <<
"
\t
Your choice is not available in Menu.
\n\t
Please try one more time.
\n
"
;
break
;
}
}
//
go back to start
case
'
0
'
:
i =
1000
;
break
;
//
default case for big switch
default
:
cout <<
"
\t
Your choice is not available in Menu.
\n\t
Please try one more time.
\n
"
;
break
;
}
//
big switch
}
//
big for
}
Back
|
FazBrowse Home
|
New Git URL