This document provides instructions for a C++ programming exam with two questions.
Question 1 asks students to design a Longtime class to represent time in hours, minutes, and seconds in 24-hour format. The class should have a constructor that initializes time to 12:00:00 and two member functions - one to find the difference between two Longtime objects and another to print the time in a.m. or p.m. format.
Question 2 asks students to design a class hierarchy for Department, Production, and Marketing classes with various data members. Students must implement the classes using C++ with appropriate constructors and a print_department_info() function. Polymorphism must be demonstrated using this
1. No. of Printed Pages : 2 SET - 1
BACHELOR IN COMPUTER APPLICATIONS (BCA)
Term-End Practical Examination
04575
June, 2011
CS-72P : C++ AND OBJECT ORIENTED PROGRAMMING
Time allowed : 2 hours Maximum Marks : 100
(Weightage : 15%)
General Instructions :
(i) There are two compulsory questions in this paper of 40 marks each. Rest 20 marks
are for viva - voce.
(ii) You must write appropriate main ( ) function and test your programs.
(iii) Write/print the programs, input and results on your answer-script.
(iv) Make and state suitable assumptions, if any.
1. Design and implement a class "Longtime" using C + + . The class "Longtime" represents 40
the time as hours, minutes and seconds using 24 hour - time format. The class should
have a constructor that initialises time to 12:00:00. The class has two member functions
as follows :-
(a) "Difference Time" which overloads the - (minus) operator to find the difference
of time stored in two different Longtime objects ; and
(b) "Print Time" that prints the time as a.m. or p.m. for example, if a Longtime object
has the time stored as 15:15:30, then this print time function will
output : 03:15:30 p.m.
2. Consider the following class hierarchy along with the suggested data members for the 40
classes
Data members :
- Dept ID
Department - Dept Name
-HOD
- Location
Production Marketing
•Expertise • Zone in India
• Product
CS-72P/S1 1 P.T.O.
2. A production department produces products in a specified product line in which the
department has expertise.
Design and implement the classes in the hierarchy using C + + . You may add more
data members in the classes, if needed. You should include at least one constructor in
each class. All the classes should have a member function "print_department_info( )"
which prints all the data of an object of that class. You should demonstrate the
polymorphism using the print_department_info( ) function along with appropriate
main ( ) function.
CS-72P/S1 2 6,000