Wanted to see if anyone could help guide me through the thinking on this question
Having written the methods to calculate areas of a square and a triangle, write a method named calcShapeArea that takes two values as x and y shown in the diagram above, and invokes calcSquareArea(x) and calcTriangleArea(x, y) to compute the area of the shape. Your expression should call the methods calcSquareArea and calcTriangleArea.
Having written the methods to calculate areas of a square and a triangle, write a method named calcShapeArea that takes two values as x and y shown in the diagram above, and invokes calcSquareArea(x) and calcTriangleArea(x, y) to compute the area of the shape. Your expression should call the methods calcSquareArea and calcTriangleArea.
Code:
public double calcShapeArea(int x, int y) {
//Write code here
}
//There's no need to modify calcSquareArea or calcTriangleArea
public double calcSquareArea(int side) {
return side * side;
}
public double calcTriangleArea(int base, int height) {
return 0.5 * base * height;
}