Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The area of a triangle (whose sides have lengths a, b and c) can be calculated using Heron's formula as shown in Eqs. (2)
The area of a triangle (whose sides have lengths a, b and c) can be calculated using Heron's formula as shown in Eqs. (2) and (3). a. (5 Marks) Write a C++ function that calculates the area of a triangle using Heron's formula. b. (10 Marks) Use the function in a program that prompts the user for the lengths of the sides of a triangle and displays the area of the triangle. a. After displaying the value, the program should indefinitely go back to prompt for the lengths of sides of the next triangle then recalculate and display the area. The program should quit when the user enters a negative number. The prompt of the program should inform the user as to how to quit it (by entering a negative number for a length of the triangle's side). c. (15 Bonus Marks) Modify the program in b. so that it takes the x, y and z coordinates as user input and then computes the lengths of the triangle's sides before computing the area. HINT: include b. c. Area, A = s(s-a)(s -b)(s-c) a+b+c 2 S= (2) (3)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Sure Heres a C program that calculates the area of a triangle using Herons formula cpp include iostr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started