Complete the following method that calculates and returns the area of a triangle using Heron's formula. To use Heron's formula, first calculate half of the perimeter of the triangle, and store it in a variable named s. Then calculate s(s - a)(s - b)(s - c), where a, b, and c are the lengths of the sides of the triangle, and the values are multiplied. The area is then the square root of that value.(10 points) The perimeter of a triangle is the sum of the lengths of the sides. public static double area(double side1, double side2, double side3) { }

Respuesta :

tonb
public static double area(double side1, double side2, double side3)
{
   double s = (side1 + side2 + side3) / 2.0;
   return Math.Sqrt(s * (s - side1) * (s - side2) * (s - side3));
}