Question: C++ program. Should be as simple as possible! This is a beginner course. No use of special characters or symbols like %!$*. Recall from geometry
C++ program. Should be as simple as possible! This is a beginner course. No use of special characters or symbols like %!$*.
Recall from geometry that corners (vertices) and angles in triangles are typically named with capital letters and the sides opposite them are named with corresponding lower case letters:
Write a program that allows the user to enter the user to enter two sides of a triangle, a and b and the measure of non-included angle A (in degrees) and prints out the measures of the other two angles (if possible).
Note that there are three possible cases - no solution, one solution, or two solutions (in which case you should print both possible pairs of angles). Look for the section called Case 2: SSA or The Ambiguous Case on this web page it shows how to identify how many answers there are:
http://mathematics.laerd.com/maths/trigonometry-sine-and-cosine-rules-intro.php
To calculate the missing angles, you will want to use the Law of Sines: a/sinA=b/sinB=c/sinC
Given a, b, and A, to find B would want to focus on: a/sinA=b/sinB
And then rewrite it to solve for sinB: sinB=b x sinA/a
Once you have sinB, you can use asin to figure out the measure of angleB (in radians!):
angle B=asin(sinB)
You can find worked samples of the math (using degrees) on this web page. Examples 3, 4, and 5 on the website match the sample runs below. http://mathematics.laerd.com/maths/trigonometry-sine-and-cosine-rules-3.php
Hints:
You will need to use pi as part of your cacluations. Doubles have an accuradcy of about 15-16 digits. So you should make sure to use that many for pi - something like 3.141592653589793. But don't use it as a "magic number" in the calculations themselves, declare a constant to holds its value.
You will have to convert between degrees and radians and vice verse. Pay attention to when you are using which unit. Good rules of thumb are: convert any degree input to radians immediately after reading it in; Then convert any angles back to degrees right before trying to print them.
Because doubles have inherit limits to their accuracy, you should not use == or != to compare them. Instead of "if x == y" you should write "if the difference between x and y is small enough". The standard way to do that is something like: abs(x - y) < 0.0001. (Book section 3.6 part 6)
Sample output:
Enter a: 28 Enter b: 15 Enter A: 110 Angle B = 30.2256 degrees Angle C = 39.7744 degrees
Enter a: 50 Enter b: 100 Enter A: 50 No solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
