subject

Given three numbers, create a class Area with following characteristics. Must extend Rectangle and Square class.
Public function named getSumOfAreas that accept two parameter of double type and return addition of those number.
Note: Rectangle and Square class already created.
Input
5.5
5.5
6.5
Where,
The first line is length of Rectangle.
The second line is width of Rectangle.
The third line is side of Square.
Output
30.25
42.25
72.50
Where,
The first line of output contains area of Rectangle.
The second line of output contains area of Square.
The third line of output contains sum of above area.
Assume that,
Inputs are in double within the range [ 1 to 10^20].
Not sure where to begin, please use code template below:
#include
#include
using namespace std;
//rectangle class
class Rectangle {
public:
double areaOfRectangle(double l, double w) {
if (l > 0 && w > 0)
return l * w;
else
return 0;
}
};
// Square class
class Square {
public:
double areaOfSquare(double s) {
if (s > 0)
return s * s;
else
return 0;
}
};
like cin/cout.
//write your code here
int main() {
double l, w,s;
Area area;
cin >> l;
cin >> w;
cin >> s;
cout << fixed << setprecision(2) << area. areaOfRectangle(l, w) << endl;
cout << fixed << setprecision(2) << area. areaOfSquare(s) << endl;
cout << fixed << setprecision(2) << area. getSumOfAreas(area. areaOfRectangle(l, w),area. areaOfSquare(s));
return 0;
}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 15:00, Siris420
Plz ( which is an example of a good url?
Answers: 1
image
Computers and Technology, 23.06.2019 20:00, shaheedbrown06
What software programs are used to to create professional publication? a.) graphics programs b.) word processors c.) page layout programs d.) spreadsheet programs
Answers: 2
image
Computers and Technology, 23.06.2019 22:30, meijorjay94p2u2zy
Apart from confidential information, what other information does nda to outline? ndas not only outline confidential information, but they also enable you to outline .
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, minecrafter3882
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe what
Answers: 1
You know the right answer?
Given three numbers, create a class Area with following characteristics. Must extend Rectangle and...

Questions in other subjects: