Advertisement
Kulas_Code20

Program

May 19th, 2022
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. #include <iostream>//Header file
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. float degree, radians, a2;
  5. const float PI = 3.142;
  6. float AreaOfTriangle(int a, int b, int c);// Function prototype with a return value of float
  7. float CalculateTheDistance(int a, int b, int c);// Function prototype with a return value of float
  8.  
  9. int main()
  10. {
  11.     int sideA, sideB, sideC; //Variable declaration
  12.    
  13.     cout<<"This program will compute the distance of the community electricity source."<<endl;
  14.     cout<<"Enter the Length of side A: ";
  15.     cin>>sideA;
  16.     cout<<"Enter the Length of side B: ";
  17.     cin>>sideB;
  18.     cout<<"Enter the value of angle between them in degree: ";
  19.     cin>>sideC;
  20.    
  21.     float distance = CalculateTheDistance(sideA,sideB,sideC);
  22.     float area = AreaOfTriangle(sideA,sideB,sideC);
  23.    
  24.     cout<<"The total value of the distance between the house A and hourse B is: " << fixed << setprecision(2) << distance <<endl;
  25.     cout<<"The total area is: "<< fixed << setprecision(2) << area <<endl <<endl;
  26.     return 0;
  27. }
  28.  
  29. float CalculateTheDistance(int a, int b, int c){
  30.     //Compute the distance
  31.     radians = (degree*PI/180); //get the value of the radian of the degree in the consines
  32.     a2 = pow(b,2) + pow(c,2) - (2*b*c*cos(radians));
  33.     a2= sqrt(a2);
  34.    
  35.     return a2;//Return the value
  36. }
  37.  
  38. float AreaOfTriangle(int a, int b, int c){
  39.     float area = (float)((1 / 2.0) * a * b * (sin(c)));
  40.    
  41.     return area;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement