CS201 Assignment no 4 Fall 2012 Idea Solution written update
Assignment |
|
Problem Statement: You are required to write a program for calculating area of Trapezoid. Formula for calculating area of trapezoid is
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.
|