8.1

Assume that a bank maintains two kinds of accounts for customers, one called as savings and the other as current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level a service charge is imposed.
Create a class account that stores customer name, account number and type of account. From this derive the classes cur_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks:

  • (a) Accept the deposit from a customer and update the balance.
  • (b) Display the balance.
  • (c) Compute and deposit interest.
  • (d) Permit withdrawal and update the balance.
  • (e) Check for the minimum balance, impose penalty, necessary and update the balance.
  • Do not use any constructors. Use member functions to initialize class members.
Answer

OUTPUT

Enter customer name :Rimo
Enter account number :10617
Enter your deposit amount : 10000
Enter today’s date(i,e day,month,year) : 13   7   2010

Now balance = 10000
press 1 to see your interest :
press 0 to skip : 1
Enter today’s date :(i,e day,month,year) 15   8   2010

Interest is : 135.61644
Enter your withdrawal amount :500
Now balance = 9635.616211

8.2

Modify the program of exercise 8.1 to include constructors for all three classes.

Answer

OUTPUT

Enter customer name :mehedi

Enter account number :1457

Enter your deposit amount : 5000

Enter your withdrawal amount :1200

Enter today’s date :(i,e day,month,year)   13   7   2010
Now balance = 4160.875977

8.3

An educational institution wishes to maintain a database of its employees. The database is divided into a number of classes whose hierarchical relationships are shown in following figure. The figure also shows the minimum information required for each class. Specify all classes and define functions to create the database and retrieve individual information as and when required.

Class-relationship

Answer

OUTPUT

About teacher:

name           code           subject                                     publication

Ataur           420          programming with c++        Tata McGraw Hill

About officer:

name                       code             Category

Md. Rashed          222               First class

About regular typist :

name                   code           speed                wage

Robiul Awal       333            85.5                   15000

About causal typist :

name                    code           speed                   wage

Kawser Ahmed   333           78.900002         10000

8.4

The database created in exercise 8.3 does not include educational information of the staff. It has been decided to add this information to teachers and officers (and not for typists) which will help management in decision making with regard to training, promotions etc. Add another data class called education that holds two pieces of educational information namely highest qualification in general education and highest professional qualification. This class should be inherited by the classes teacher and officer. Modify the program of exercise 8.19 to incorporate these additions.

Answer

OUTPUT

About teacher:

name    code        subject                 publication             qualification

Ataur    420  programming with c++   Tata McGraw Hill   PHD from programming-
About officer:

name                  code        Catagory                  Qualification

Md. Rashed      222         First class                2 years experienced

About regular typist :

name                code          speed             wage

Robiul Awal     333          85.5                15000
About causal typist :

name               code         speed             wage

Kawser           333          78.900002    10000

8.5

Consider a class network of the following figure. The class master derives information from both account and admin classes which in turn derives information from the class person. Define all the four classes and write a program to create, update and display the information contained in master objects.

Ques-Figure

Answer

OUTPUT

name         code          Experience              payment

Hasibul    111              3 years                      1500tk

8.6

In exercise 8.3 the classes teacher, officer, and typist are derived from the class staff. As we know we can use container classes in place of inheritance in some situations. Redesign the program of exercise 8.3 such that the classes teacher, officer and typist contain the objects of staff.

Answer

OUTPUT

About teacher:

name       code        subject                          publication

Ataur   420     programming with c++   Tata McGraw Hill

About officer:

name                code             Catagory

Md. Rashed     222             First class

About typist :

name                  code             speed

Robiul Awal     333               85.5

8.7

We have learned that OOP is well suited for designing simulation programs. Using the techniques and tricks learned so far, design a program that would simulate a simple real-world system familiar to you

Answer

OUTPUT

Enter student name : santo

Enter roll: 156271

marks of  :

Bangla 1st paper = ? 74

Bangla 2nd paper = ? 87

English 1st paper = ? 45

English 2nd paper = ? 56

Mathematics = ? 87

Religion = ? 59

Physics = ? 75

Chemistry = ? 65

Sociology = ? 39

Higher Mathematics = ? 86

result of

name :santo

Roll : 156271

Subject                                     Marks         GPA            Grade

Bangla 1st paper                      74                 4                  A

Bangla 2nd paper                     87                5                 A+

English 1st paper                     45                 2                   C

English 2nd paper                   56                 3                 B

Mathematics                            87                 5                  A+

Religion                                   59                 3                  B

Physics                                     75                 4                  A

Chemistry                               65                 3.5              A-

Sociology                                39                 1                  D

Higher Mathematics           86                 5                 A+


Next Previous