You are on page 1of 1

Object Oriented Programing

Lab task 4

Q1. Create a class named Student. It contains two private members


name, marks. Create a constructor that initializes the data; name to an
empty String and marks as zero. Create two functions input() and
display(). Input() takes value from user and display() displays the values
of name and marks.
Q2. Create a class Counter with an integer data member. Write one
method to get value of counter, one to increment counter, one to
decrement the counter and one to reset counter to zero. Make sure that
value of counter never gets less than zero.do we need to create a
constructor in this class?
Q3. Create a class Distance contains two data items, feet and inches.The
class Distance also has three member functions: setdist(), which uses
arguments to set feet and inches; getdist(), which gets values for feet and
inches from the user at the keyboard; and showdist(), which displays the
distance in feet-and-inches format. The value of an object of class
Distance can thus be set in either of two ways. In main(),define two
objects of class Distance. The first is given a value using the setdist()
member function with the arguments and the second is given a value
that is supplied by the user. Then display the two distances.

You might also like