-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw1.cpp
33 lines (25 loc) · 996 Bytes
/
hw1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;
using std::string;
// Write a program that asks the user for sets the length of side a = 3 and side b = 4.
//From those two (2) variables calculate the hypotenuse, angle A (𝛳1), and angle B (𝛳2) for a right triangle. [Hint: For the angles SOHCAHTOA]
int main() {
double side_a;
double side_b;
double PI = 3.14159265;
cout << "Enter side a value\n";
cin >> side_a;
cout << "Enter side b value\n";
cin >> side_b;
cout << "With a side a of " << side_a << " and a side b of " << side_b << endl;
double hypotenuse = sqrt(pow(side_a, 2) + pow(side_b, 2));
cout << "The hypotenuse is = " << hypotenuse << endl;
double angle_A = asin(side_a / hypotenuse) * (180 / PI);
double angle_B = asin(side_b / hypotenuse) * (180 / PI);
cout << "The angle 1 is = " << angle_A << " degrees" << endl;
cout << "The angle 2 is = " << angle_B << " degrees" << endl;
}