Define a class area that has following members:
Private Variables: Side1, side 2, radius: two parametriced constructor use to assign values to sides and radius.
Public method: rect_area() to calculate calculate area of rectangle.
circ_area () to calculate area of circle.
Public method main invokes all member method and print the result
Answers
Answer:
Suppose we have taken length and breadth of two rectangles, and we want to calculate their area using class. So we can make a class called Rectangle with two attributes l and b for length and breadth respectively. And define another function called area() to calculate area of that rectangle.
So, if the input is like (10,9), (8,6), then the output will be 90 and 48 as the length and breadth of first rectangle is 10 and 9, so area is 10 * 9 = 90, and for the second one, the length and breadth is 8 and 6, so area is 8 * 6 = 48.
To solve this, we will follow these steps −
Define rectangle class with two attributes l and b
define input() function to take input for l and b
define area() function to return l * b, which is the area of that rectangle
Explanation:
You can use the Alignment tab in the Format Cells dialog box to manually set the text direction Side1, side 2, radius: two parametriced constructor use to assign values to sides and radius.
Public method: rect_area() to calculate calculate area of rectangle.
circ_area () to calculate area of circle.
Public method main invokes all member method and print the result