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

Hello, I need some assistance coding the following in C++, preferably with g++ c

ID: 3754528 • Letter: H

Question

Hello, I need some assistance coding the following in C++, preferably with g++ compiler. Sample outputs provided for reference, thanks.

Sample Run 1 TRIANGLES Enter length of first side: 5 Enter length of second side: 5 Enter length of third side: 5 You entered sides of length 5, 5 and 5 perimeter = 15 rea10.8253 The triangle isan equilateraltriangle The triangle is an isosceles triangle Sample Run 2 TRIANGLES Enter length of first side: 3.1 Enter length of second side: 4.2 Enter length of third side: 5.7 You entered sides of length 3.1, 4.2 and 5.7 perimeter = 13 ea6.37683 Sample Run 3 TRIANGLES Enter length of first side: 3 Enter length of second side:7 Enter length of third side: 3 You entered sides of length 3, 7 and 3 These three side lengths cannot form a legal triangle

Explanation / Answer

//C++ program

#include <iostream>

#include <math.h>

using namespace std;

void type_of_triangle (double a,double b,double c){

if(a==b&&b==c&&c==a){

cout<<"This is an euilateral triangle ";

cout<<"This is an isosceles triangle ";

}

else if(a==b||b==c||c==a){

cout<<"This is an isosceles triangle ";

}

else cout<<"This is an scalene triangle ";

}

double area (double a ,double b ,double c){

double s =(a+b+c)/2;

return sqrt(s*(s-a)*(s-b)*(s-c));

}

int main(){

double a,b,c;

cout<<"enter three sides of triangle ";

cout<<"a = ";

cin>>a;

cout<<" b = ";

cin>>b;

cout<<" c = ";

cin>>c;

cout<<"you entered side of length "<<a<<","<<b<<" and "<<c<<" ";

if((a+b>c)&&(a+c>b)&&(b+c>a)){

type_of_triangle(a,b,c);

cout<<" perimeter = "<<(a+b+c)<<" ";

cout<<" Area = "<<area (a,b,c)<<" ";

}

else cout<<"These side length cannot form a legal triangle ";

return 0;

}

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