CoSc 200 Laboratory #3
Triangle Calculator
The triangle calculator allows you construct a triangle by clicking where the three vertices should be. The mouse coordinates are displayed while you are determining the three points. In addition to drawing the triangle, the calculator displays the perimeter, area, degree measurements of the three angles, and the median lines. Try out this demo!
Your goal is to implement your own version of the triangle calculator as an applet.
Before you begin, you should organize yourself: create a lab folder, obtain and save template files with suitable names (for example, "TriangleCalculator.java" and "TriangleCalculator.htm"), read the rest of this lab description, and make a plan of action.
It is a good practice to develop programs incrementally. Start with one part of the program, develop the code for it, test it, correct it, test it, correct it, ..., correct it, and test it until that single part works well. Then move to another part and repeat the "develop, test, and correct" cycle until that second part works well. Continue with the third part, fourth part, fifth part, and so forth until the whole program is working well. If you develop your program incrementally, you will complete the program faster, with less frustration, and with a greater sense of accomplishment. Study the demo version and the list of correctness items in the grading guidelines to help you determine your plan.
Suppose the length of the three sides are a, b, and c. Then
![]()
![]()
where
![]()
and

is the radian measure of the angle at the point A. The formulas for the other angles can be obtained by permuting the side lengths in the above formula.
A median line for a triangle is determined by a vertex and the midpoint of the opposite side.
Value
Feature Style, Design, and Efficiency 3Includes informative comments. In particular, there is a description of the program, the author's name, a date, and an acknowledgement statement at the top of the file, and above each method is a description, in general terms, of what that method does. 3Uses appropriate names and scope for variables, constants, methods, and classes. 2Uses appropriate formatting. 2Uses efficient code. Specifically, the code is clear, avoid duplications, and generates new objects only when necessary. Correctness 1Instruction changes when user clicks. 1Mouse position is displayed. 1Lines appear before the second and third clicks while the mouse is moved. 1Triangle is displayed. 1Perimeter is diplayed. 1Area is displayed. 1Angles are displayed. 1Perimeter, area, and angle measurements are displayed nicely formatted. 1Median lines are displayed 1Canvas is reset after the fourth click
Make sure your work is ready to submit. Return to JCreator and double check that you included your name, the date, and an acknowledgement statement in a comment at the start of your ".java file", your ".java" file compiles successfully, and the program executes correctly.
To submit your work.
Submission Deadline: 3:00pm on Tuesday, January 24. Note that once you submit, it is impossible to submit a revision.
Resubmission and Late Submission Deadline: 3:00pm on Tuesday, January 31. A 5 point penalty will be assessed for a resubmission or late submission. These should be submitted to Lab03Late.