OOPs LAB  (OBJECT ORIENTED PROGRAMMING LAB)

DCRUST SYLLABUS

CSE381C   OBJECT ORIENTED PROGRAMMING LAB

CATEGORY : ENGINEERING SCIENCE COURSE

Course Objectives:

  1. To apply the basic knowledge of Object and classes.
  2. To implement features of Object oriented programming like inheritance, polymorphism, operator overloading
  3. To apply the concepts of exception handling and templates.

List of hands-on experiments related to the course contents of CSE301C.

  1. Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called power ( ) that takes a double value for n and an int value for p, and returns the result as double value Use a default argument of 2 for p. so that if this argument is omitted, the number will be squared. Write a main ( ) function that gets values from the user to test this function.
  2. Create the equivalent of a four function calculator. The program should request the user to enter a number, an operator, and another number. It should then carry out the specified arithmetical operation: adding. subtracting, multiplying, or dividing the two numbers. (It should use a switch statement to select the operation). Finally it should display the result. When it finishes the calculation, the program should ask if the user wants to do another calculation. The response can be ‘Y’ or ‘N’. Some sample interaction with the program might look like this. Enter first number. Operator, second number: 10/3 Answer = 3.333333 Do another (YI N)? Y Enter first number. Operator, second number 12 + 100 Answer = 11  Do another (Y I N)? N
  3. Write a program to overload constructors.
  4. Create two classes DM and DB which store the value of distances. DM stores distances in metres and centimeters and DB in feet and inches. Write a program that can read values for the class objects and add one object of DM with another object of DB. Use a friend function to carry out the addition operation. The object that stores the results maybe DM object or DB object. depending on the units in which the results are required. The display should be in the format of feet and inches or metres and centimetres depending on object on display.
  5. Write a Program to overload +,-,*,/,+= on a class of complex numbers.
  6. Write a Program to overload +,== on a class of strings.
  7. Create a class rational which represents a numerical value by NUMERATOR & DENOMINATOR . Write a Program to overload +,- for class of rational .
  8. Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type string. Supply a method to toString that prints the manager’s name, department and salary. Make a class Executive inherit from Manager Supply a method to String that prints the string Executive followed by the information stored in the Manager superclass object. Supply a test program that tests these classes and methods.
  9. Imagine a tollbooth with a class called toll Booth. The two data items of 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 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.
  10. Write a program to create a class template to implement stack operations.
  11. Write a program to demonstrate exception handling.

Course Outcomes:  After successful completion of the course, a student will be able to :-

  1. Develop program using the concepts of object oriented programming like class, objects, constructors and destructors.
  2. Develop  programs using C++ features such as Operator overloading and
  3. Develop programs to illustrate virtual functions and friend functions.
  4. Develop programs to apply the concepts of templates and exception handling
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.