197k views
1 vote
To determine if data entered represents a right triangle and compute the area of a triangle if it is a right triangle...leg1 times leg2 divided by 2

1. Modify the getTopping method from the Pizza Case Study (week 5: found below) so that will be used to input 1 side of a triangle...rename the method getTriangleside
a. This method will be invoked 3 times ...each time it will return 1 side of a triangle
b. The number input must be an integer and it must be greater than 0

User SLLegendre
by
8.1k points

1 Answer

1 vote

Final answer:

The Pythagorean Theorem is used to determine if data represents a right triangle and calculate the area of a right triangle. The formula to calculate the area of a right triangle is (leg1 x leg2) / 2. The 'getTrianglesidea' method can be modified from the 'getTopping' method to input one side of a triangle.

Step-by-step explanation:

Pythagorean Theorem

The Pythagorean Theorem states that in a right triangle, the square of the length of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. It can be written as: a² + b² = c², where 'a' and 'b' are the lengths of the two legs of the triangle and 'c' is the length of the hypotenuse.

Area of a Right Triangle

To calculate the area of a right triangle, you can use the formula: (leg1 x leg2) / 2. In this formula, 'leg1' and 'leg2' represent the lengths of the two legs of the triangle. Simply multiply the lengths of the two legs and divide the result by 2 to get the area of the triangle.

getTrianglesidea Method

In the given question, you are asked to modify the 'getTopping' method from the Pizza Case Study to a new method called 'getTrianglesidea'. This new method will be used to input one side of a triangle. It should be invoked three times, and each time it should return one side of a triangle as an integer greater than 0.

User Manuel G
by
8.1k points