The area of an arbitrary triangle can be computed using the formula area = √(s(s–a)(s–b)(s–c)) where the square root is applied to the entire product (Links to an external site.) and where a, b, and c are the lengths of the sides, and s is the semiperimeter of the triangle given (Links to an external site.) by the formula: s = (a + b + c)/2 EXTRA CREDIT: 10 points for adding a function named getInput that initializes the three side lengths from outside of main. Write a void function named (Links to an external site.) triangle that computes the area and perimeter (as well as the semiperimeter which will be used to compute the area) of a triangle based (Links to an external site.) on the length of the sides. The function should use five parameters (Links to an external site.)—three value (Links to an external site.) parameters (Links to an external site.) that provide the lengths of the edges and two reference parameters (Links to an external site.) that store (Links to an external site.) the computed area and perimeter respectively. Make your function robust. Note that not all combinations of a, b, and c produce a triangle. Your function should produce correct results for legal data and reasonable results for illegal combinations. Include in your submission a driver that repeatedly reads in 3 positive numbers that are the sides of a triangle, and each time print out the sides and the area and perimeter calculated by the triangle function.
The area of an arbitrary triangle can be computed using the formula area = √(s(s–a)(s–b)(s–c)) where the square root is applied to the entire product (Links to an external site.) and where a, b, and c are the lengths of the sides, and s is the semiperimeter of the triangle given (Links to an external site.) by the formula: s = (a + b + c)/2 EXTRA CREDIT: 10 points for adding a function named getInput that initializes the three side lengths from outside of main. Write a void function named (Links to an external site.) triangle that computes the area and perimeter (as well as the semiperimeter which will be used to compute the area) of a triangle based (Links to an external site.) on the length of the sides. The function should use five parameters (Links to an external site.)—three value (Links to an external site.) parameters (Links to an external site.) that provide the lengths of the edges and two reference parameters (Links to an external site.) that store (Links to an external site.) the computed area and perimeter respectively. Make your function robust. Note that not all combinations of a, b, and c produce a triangle. Your function should produce correct results for legal data and reasonable results for illegal combinations. Include in your submission a driver that repeatedly reads in 3 positive numbers that are the sides of a triangle, and each time print out the sides and the area and perimeter calculated by the triangle function.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images