Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Note: For computer language, please use the one used in the program \"Dev C++.\"

ID: 2247408 • Letter: N

Question

Note: For computer language, please use the one used in the program "Dev C++." Thank you.

Write a program to calculate the remaining one side and two angles for a triangle given two sides and one opposite angle using the law of sines, as illustrated below. Units are not required for the sides.

Inputs: sides a, b, and angle A (in degrees)

Outputs: angles B and C and side c (add the word degrees after each angle)

Turn in a printout of the program and printouts for all required test cases.

Testing: Run the program for the three cases shown below (answers shown for Case 1 in example below):

Case

side a

side b

angle A

1

20

10

30°

2

7.5

10.5

40°

3

100

100

60°

Case

side a

side b

angle A

1

20

10

30°

2

7.5

10.5

40°

3

100

100

60°

Explanation / Answer

So here is your program with well explained comments :

#include <iostream>
#include <math.h>

using namespace std;

#define PI 3.14159265

int main () {

double side_a,side_b,side_c,angle_A,angle_B,angle_C;
cin >> side_a >> side_b >> angle_A;


// law of sines says that for given sides a,b,c and respective opposite angles A,B,C of a triangle,
// sin A / a = sin B / b = sin C / c = K (constant)

// Please make note that c++ functions take input for angles in radians only so for conversion of angle in degrees to radians we multiply by PI / 180
// and for reverse i.e radians to degrees we multiply by 180 / PI


double K = sin(angle_A*PI/180)/side_a; // constant ratio....

// using law of sines we have sin B / b = K .... so sin B = b*K

double sin_angle_B = side_b*K;

// taking inverse sine to get the angle in radians and then converting it into degrees by multiplying by 180 / PI
angle_B = asin(sin_angle_B)*180/PI;

// Sum of all angles of a triangle is 180 degrees so A + B + C = 180
angle_C = 180.0000000-angle_A - angle_B;

// Using law of sines again, we have sin C / c = K so c = sin C / K

side_c = sin(angle_C*PI/180) / K; // note the nagle is converted from degrees to radians

cout << "Angle B is " << angle_B << " degrees, Angle C is " << angle_C << " degrees and side C is " << side_c << " units ";

return 0;
}


Answers for the 3 cases :

Angle B is 14.4775 degrees, Angle C is 135.522 degrees and side C is 28.0252 units

Angle B is 64.1453 degrees, Angle C is 75.8547 degrees and side C is 11.3141 units

Angle B is 60 degrees, Angle C is 60 degrees and side C is 100 units

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote