Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath.h>
- class Triangle{
- private:
- float a;
- float b;
- float theta;
- public:
- Triangle(float first,float second,float angle);
- void setA(float first) ;
- void setB(float second) ;
- void setTheta(float angle);
- float getA() const;
- float getB() const;
- float getTheta() const;
- float thirdSide() const;
- };
- Triangle::Triangle(float first,float second,float angle){
- a = first;
- b = second;
- theta = angle;
- }
- void Triangle::setA(float first)
- {
- a = first;
- }
- void Triangle::setB(float second)
- {
- b = second;
- }
- void Triangle::setTheta(float angle)
- {
- angle = theta;
- }
- float Triangle::getA()
- {
- return a;
- }
- float Triangle::getB()
- {
- return b;
- }
- float Triangle::getTheta()
- {
- return theta;
- }
- float Triangle::thirdSide() const
- {
- float third;
- third = Math.sqrt(a^2 + b^2 - (2*b*a*Math.cos(theta)));
- return thrid;
- }
- #include <iostream>
- using namespace std;
- #include "triangle.h"
- int main()
- {
- float a,b,theta;
- a = cin<<"Enter side A:";
- b= cin<<"Enter side B: ";
- theta = cin<<"Enter angle theta: ";
- Triangle tri(10,20,30);
- cout>>"The third side is: ">>tri.getThirdside;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement