You are required to write a program for calculating area of Trapezoid. Formula for calculating area of trapezoid is
((a+b)/2 )*h
Where a and b are two bases of trapezoid and h corresponds to height.
Detailed Description:
Create a class named Trapezoid which contains two bases and height as data members.
Implement a default constructor to initialize all data members with zero and a parameterized constructor which takes three arguments to initialize data members of class.
Take input from user for base1, base2 and height of 2 objects.
Overload + operator for the class Trapezoid in such a way that corresponding elements of both objects of the same class can be added.
Also implement a friend function named calculateArea() which takes two objects of the class Trapezoid as arguments, adds both objects using overloaded + operator and calculates the area of resultant Trapezoid object.
This sort of problem can be built up one step at a time, starting with something simple and adding code for each additional requirement. Please let us know how far you have got so far, and where you are stuck.
This seems working fine mahi shah, i just checked it out.. i didn't understand your purpose of get and set methods because you can directly pass those parameter during object initialization and i think there is no mention of get and set method in detailed description..
you can use proper naming and programing convention so that it becomes more readable and easily understandable..
like, proper spacing, how to name calss and object, proper commenting, etc..