Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Notes: Name the function TriCompute() (with appropriate parameters and return ty

ID: 3686823 • Letter: N

Question

Notes:

Name the function TriCompute() (with appropriate parameters and return type specified in the question).

The triangle inequality states that the sum of the lengths of any two sides of a triangle must be greater than or equal to the length of the third side.  So you should check for this property first before computing the area and perimeter -- before you call the function. If a given set of side lengths do not conform to this property, you should REAPEATEDLY ASK THE USER to enter valid values.

You do not have to repeat the session.

Sample user interaction is shown below.

The area of an arbitrary triangle can be computed using the formula Area = sqrt(s(s-a) * (s - b) * (s - c)), where a, b, and c are the lengths of the sides, and s is the semiperimeter. s = (a + b + c)/2.  Write a void function that uses five parameters: three value parameters that provide the lengths of the edges, and two reference parameters that compute the area and perimeter ( not the semiperimeter ). 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.

Explanation / Answer

#include<iostream.h>
#include<cmath.h>
#include<conio.h>
using namespace std;

int main()
{
clrscr();
double area,perimeter;
double a,b,c;
bool TriCompute(double&,double&,double,double,double);
cout<<"enter area,perimeter and sides of triangle";
bool B=TriCompute(area,perimeter,a,b,c);
if(true)
{
cin>>a>>b>>c>>area>>perimeter;
cout<<"the area os triangle with sides of length"<<a<<","<<b<<","<<c
<<"area is"<<area<<"and perimeter is"<<perimeter;
}
getch();
return 0;
}

bool TriCompute(double& area,double& perimeter,double a,double b,double c)
{
int s;
if( (a<(b+c))&&(b<(a+c))&&(c<(b+a)) )
{
s = (a + b + c)/ 2.0;
area = sqrt (s*(s-a)*(s-b)*(s-c));
perimeter=a+b+c;
}
else
{
cout<<"your entered values are didn't match the criteria"<<endl;
return false;
}
return true;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote