Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <cmath.h>
  2. class Triangle{
  3.     private:
  4.         float a;
  5.         float b;
  6.         float theta;
  7.     public:
  8.         Triangle(float first,float second,float angle);
  9.         void setA(float first) ;
  10.         void setB(float second) ;
  11.         void setTheta(float angle);
  12.         float getA() const;
  13.         float getB() const;
  14.         float getTheta() const;
  15.         float thirdSide() const;
  16. };
  17. Triangle::Triangle(float first,float second,float angle){
  18.     a = first;
  19.     b = second;
  20.     theta = angle;
  21. }
  22. void Triangle::setA(float first)
  23. {
  24.     a = first;
  25. }
  26. void Triangle::setB(float second)
  27. {
  28.     b = second;
  29. }
  30. void Triangle::setTheta(float angle)
  31. {
  32.     angle = theta;
  33. }
  34. float Triangle::getA()
  35. {
  36.     return a;
  37. }
  38. float Triangle::getB()
  39. {
  40.     return b;
  41. }
  42. float Triangle::getTheta()
  43. {
  44.     return theta;
  45. }
  46. float Triangle::thirdSide() const
  47. {
  48.     float third;
  49.     third = Math.sqrt(a^2 + b^2 - (2*b*a*Math.cos(theta)));
  50.     return thrid;
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. #include <iostream>
  65. using namespace std;
  66. #include "triangle.h"
  67.  
  68. int main()
  69. {
  70.     float a,b,theta;
  71.     a = cin<<"Enter side A:";
  72.     b= cin<<"Enter side B: ";
  73.     theta = cin<<"Enter angle theta: ";
  74.     Triangle tri(10,20,30);
  75.     cout>>"The third side is: ">>tri.getThirdside;
  76.    
  77.     return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement