4. The following problem refers a mamod 4.a. Write the class definition of trian
ID: 3583156 • Letter: 4
Question
4. The following problem refers a mamod 4.a. Write the class definition of triangleTspe ()the class has three memier satiabies siada 2) the class has the following memiher funciims vatiities Constructor(s) to initialize the meniber so value set All-has three parameters. returns the isRight-retums true if the triangle isatigh mangit otimi m siate A triangle is a right triangle inside siaal Note that in order for isRight to fun member variables have make sure tinar 4 b Write the definitions (implementations of time menihe imtim diii iias (Use additional paper for your answer) 4.c Assume that the code of parts 4.a. and 4 b is stored initie fiertnia program to declare triangleType objects and test the performumo oft aias tuudiosi one of your objects so sideA will be sideB will be4 amisideoMillit (Use additional paper for your answer)Explanation / Answer
#include<bits/stdc++.h>
using namespace std;
class triangleType
{
int SideA,SideB,SideC;
public:
triangleType()
{
SideA=0;
SideB=0;
SideC=0;
}
triangleType(int a,int b,int c)
{
SideA=a;
SideB=b;
SideC=c;
}
void setAll(int a,int b,int c)
{
SideA=a;
SideB=b;
SideC=c;
}
int computePerimeter()
{
return SideA+SideB+SideC;
}
bool isRight()
{
if(SideC*SideC==(SideB*SideB+SideA*SideA))
return true;
return false;
}
};
int main(int argc, char const *argv[])
{
triangleType t;
int a,b,c;
cout<<"Enter Side A ";
cin>>a;
cout<<"Enter Side B ";
cin>>b;
cout<<"Enter Side C ";
cin>>c;
t.setAll(a,b,c);
cout<<"Perimeter is "<<t.computePerimeter()<<endl;
if(t.isRight())
{
cout<<"Triangle is right angled ";
}
else
{
cout<<"Triangle is not right angled ";
}
return 0;
}
========================================================
Output:
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Enter Side A
3
Enter Side B
4
Enter Side C
5
Perimeter is 12
Triangle is right angled
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.