Você está na página 1de 3

SINHGAD INSTITUTE OF BUSINESS ADMINISTRATION AND RESEARCH

Class: MCA – Sem III Subject: C++

Date: 02/08/10 Assignment: 6 Submission Date:11/08/10

1. Create a base class math_operations, which accepts numbers from user. Derive
two classes, Add and Multiply from it to perform the corresponding operations.

2. Design a hierarchy of toys. The base class is a toy. Derived classes are stuffed
toy, battery power toy and mechanical toy. Write a program to demonstrate
single inheritance.

3. Write a C++ program to implement multilevel inheritance. Use a base class


Student, intermediate base class as test and Derived base class as Result.

4. Create class employee with data members emp_no, emp_name, and basic_sal.
Derive a class officer from employee who gets additional traveling allowance
(10% of basic). Derive a class manager from officer who gets a special children
educational allowance (Rs. 5000/-). Write the necessary member functions to
accept and display details. Write a function in each class which displays the total
salary.

5. Write a base class student(roll_no,name). Derive two classes Science(maths, phy,


comp) and Commerce(acc, stats) from it. Accept details of students, they could
be from science or commerce. Display the details of all students in same order of
acceptance.

6. Imagine a publishing company that markets both book and audio cassette versions
of its works. Create a class publication that stores the title and price of a
publication. From this class derive two classes book, which adds a pagecount and
tape, which adds a playing time in minutes. Each of these three classes should
have getdata () functions to get its data from the user and putdata () to display its
data. Write a main () program to test book and tape classes by creating instances
of them asking the user to fill in their data with getdata () and then displaying the
data with putdata ().

7. Create a base class called shape. Use this class to store double type values that
could be used to compute the area of figures. Derive two specific classes called
triangle and rectangle from the base shape. Add to the base class, a member
function get_data( ) to initialize base class data members and another member
function disp_area( ) to compute and display area of figures. Make disp_area( ) as
a virtual function and redefine it in the derived classes to suit their requirements.

8. Write string class as a base class, derive a class pstring i.e. protected string that
prevents buffer overflow when too long string constant is used in a definition. A
new constructor in the derived class should copy only size – 1 characters into str
if the string constant is longer, but copy the entire constant if it is shorter. Write a
main program to test different lengths of strings.
9. Consider the class network of figure mentioned below. The class master derives
information from both account and admin classes, which in turn derive
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.
person
name
code

admin
account
pay experience

master
name
code
experience
pay

10. Assume that a bank maintains two kinds of accounts for customers, one called as
saving account and the other as current account. The saving 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 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, if
necessary, and update the balance.
Do not use any constructor. Use member functions to initialize the class members.

11 Develop an object oriented program in c++ to create a library information system


containing the following for all books in library:
• Accession number
• Name of the author
• Title of book
• Year of publication
• Publisher’s name
• Cost of book

Design a base class with data members, accession number, name of the author and title of
the book and another base class containing year of publication and publisher’s name. The
derived class consists of the data member and cost of the book.

Construct an object oriented data base carry out the following methods:

Build a master table


List a table
Insert a new entry
Delete old entry
Edit entry
Sort entries
Search for a record that is to be printed.

12. Develop a program for creating a database of the personnel information system
containing the following information:
Name
Date of Birth
Blood group
Height
Weight
Insurance policy number
Contact address
Telephone number
Deriving License number etc

Design a base class with name, date of birth, blood group and another base class
consisting of the data member such as height and weight. Design one or more base class
consisting of the insurance policy number and contact address. The derived class contains
the data members of the telephone number and driving licence number.

**********************************************************************

Você também pode gostar