At the completion of this project, you will have created an application that
In this week's labs you wrote programs that calculated the length of the hypotenuse of a right triangle, given the length of the other two sides. In this project you will create a Program that calculates the length of one side of a triangle, given the lengths of the other two sides and the value of the included angle. The triangle need not be a right triangle. See the image below:
Using the law of Cosines, we have the following formula for finding the length of the side c, given the lengths of sides a and b, and the value of the angle C:
c^{2} = a^{2} + b^{2} - 2abCos(C)
When the included angle is 90^{o} the cosine of 90^{o} is zero, and so we end up with the pythagorean theorem that you used in labs 10 and 11.
For this project you will create a Graphical User Interface program. You can design your own interface, but it must be intuitive and easy to use. Your interface must include working Exit and About menu items. An example of what you interface could looks like is shown in the figure below.
The user will input the lengths of two adjacent sides of the triangle and the value of the included angle, in degrees. The program will compute and display the length of the other side of the triangle.
Your program must include a method that takes three parameters: The lengths of the two adjacent sides of the triangle, and the value of the included angle, in degrees. The method will return the length of the third side.
Display your answer accurately with two digits after the decimal point.
When you are satisfied that your program works correctly, format and document your code in accordance with the style guide. Watch for magic numbers! Include a file prologue identifying you as the author. Be sure that you have complete method prologues that conform to the style guide. Submit your project using the instructions outlined in the Course Syllabus, Programming Projects section.
Place your complete project folder into
a zip file and name the zip file
proj_04_your-initials_V1.0.zip.
For example, I would name my file proj_04_RKD_V1.0.zip.
Submit this assignment as Project #4 on Canvas.
The Math class contains a method, Math.Cos( ), that returns the cosine of an angle, given the size of the angle in radians. In this problem we expect the user to enter in the size of the angle in degrees, so we have to convert the size of the angle into radians first. There are 2Pi radians in a circle, so to convert the size of an angle in degrees into radians, you have to multiply the size of the angle by pi and divide the result by 180.
Description | Points possible | Your points |
Project meets the following guidelines:
| 5 | |
Program contains a method that calculates the length of one side of a triangle, give the lengths of the other two sides and the included angle, as explained in the instructions. |
5 | |
Program meets all requirements and correctly calculates and displays the length of the other side of the triangle. |
10 | |
Extra Credit:Research the Law of Cosines and write additional methods to calculate the values of the other two angles using the Law of Cosines. Display them correctly. |
5 | |
Early Bonus (+3 pts) or late penalty (-20% per day) | ||
Total |
20 |
You can get an executable that runs correctly here!