The document provides instructions for three object-oriented programming lab tasks. Task 1 involves creating a Student class with private name and marks members, and input and display methods. Task 2 involves creating a Counter class with an integer member, and methods to get, increment, decrement, and reset the counter value. Task 3 involves creating a Distance class with feet and inches members, and setdist, getdist, and showdist methods to set values, get user input, and display distances in a feet-inches format.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
21 views
Object Oriented Programing Lab 4
The document provides instructions for three object-oriented programming lab tasks. Task 1 involves creating a Student class with private name and marks members, and input and display methods. Task 2 involves creating a Counter class with an integer member, and methods to get, increment, decrement, and reset the counter value. Task 3 involves creating a Distance class with feet and inches members, and setdist, getdist, and showdist methods to set values, get user input, and display distances in a feet-inches format.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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.