Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>//Header file
- #include <bits/stdc++.h>
- using namespace std;
- float degree, radians, a2;
- const float PI = 3.142;
- float AreaOfTriangle(int a, int b, int c);// Function prototype with a return value of float
- float CalculateTheDistance(int a, int b, int c);// Function prototype with a return value of float
- int main()
- {
- int sideA, sideB, sideC; //Variable declaration
- cout<<"This program will compute the distance of the community electricity source."<<endl;
- cout<<"Enter the Length of side A: ";
- cin>>sideA;
- cout<<"Enter the Length of side B: ";
- cin>>sideB;
- cout<<"Enter the value of angle between them in degree: ";
- cin>>sideC;
- float distance = CalculateTheDistance(sideA,sideB,sideC);
- float area = AreaOfTriangle(sideA,sideB,sideC);
- cout<<"The total value of the distance between the house A and hourse B is: " << fixed << setprecision(2) << distance <<endl;
- cout<<"The total area is: "<< fixed << setprecision(2) << area <<endl <<endl;
- return 0;
- }
- float CalculateTheDistance(int a, int b, int c){
- //Compute the distance
- radians = (degree*PI/180); //get the value of the radian of the degree in the consines
- a2 = pow(b,2) + pow(c,2) - (2*b*c*cos(radians));
- a2= sqrt(a2);
- return a2;//Return the value
- }
- float AreaOfTriangle(int a, int b, int c){
- float area = (float)((1 / 2.0) * a * b * (sin(c)));
- return area;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement