Professional Documents
Culture Documents
5. A class Student has name (char name[20]) and age(int). Define the
default constructor, member functions get_data() for taking the name
and age of the Student, print() for displaying the data of Student.
3 Group C 1. A class Patient that stores the patient name (a string) and the disease
(16BCE1025 (a string) of the patient. From this class derive two classes :
-1040)
In_patient which has a data member roomrent (type float) and
Out_patient which has a data member OPD_charges (float). Each of
these three classes should have a nondefault constructor and a
putdata() function to display its data. Write a main() program to test
In_ patient and Out_patient classes by creating instances of them and
then displaying the data with putdata().
2. A derived class having following items: name, age, rollno, marks,
empcode and designation. Design a base class student having data
members as rollno, marks and the another base class is employee
having data members as empcode and designation. These both base
classes are inherited from a single base class person with data
members name and age. The program should carry out the required
input( ) and output( ) member functions for all.
hours
minutes
second
Write a C++ program using operator overloading for the
following:
i. .= = to check whether two Times are same or not.
ii. >>to accept the time.
iii. <<to display the time .
1100.00 1 100.00
5. Assume that the cell users are two kinds those with a
post paid option and those with a prepaid option. Post
paid gives a fixed free talk time and the rest is
computed at the rate of Rs.1.90 per pulse. Prepaid
cards have a fixed talk time. Define a class Cell_user
as a base class and derive the hierarchy of classes.
Define member functions and override them wherever
necessary to
5. Model this tollbooth with a class called tollBooth. The two data
items are a type unsigned int to hold the total number of cars, and a
type double to hold the total amount of money collected. A
constructor initializes both of these to 0. A member function called
payingCar() increments the car total and adds 0.50 to the cash total.
Another function, called nopayCar(), increments the car total but
adds nothing to the cash total. Finally, a member function called
display() displays the two totals. Make appropriate member
functions const. Include a program to test this class. This program
should allow the user to push one key to count a paying car, and
another to count a nonpaying car. Pushing the Esc key should cause
the program to print out the total cars and total cash and then exit.
7 Group G 1. Create a class called bMoney. It should store money amounts as long
(16BCE1076 doubles. Use the function mstold()to convert a money string entered
-1471) as input into a long double, and the function ldtoms() to convert the
long double to a money string for display. You can call the input and
output member functions getmoney() and putmoney(). Write another
member function that adds two bMoney. Just add the long double
member data amounts in two bMoneyobjects. Write a main()
program that repeatedly asks the user to enter two money strings,
and then displays the sum as a money string.