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.

Some mathematical formulas and defintions

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.

Grading Guidelines

Value

Feature
   Style, Design, and Efficiency
3
Includes 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.
3
Uses appropriate names and scope for variables, constants, methods, and classes.
2
Uses appropriate formatting.
2
Uses efficient code. Specifically, the code is clear, avoid duplications, and generates new objects only when necessary.
  
Correctness
1
Instruction changes when user clicks.
1
Mouse position is displayed.
1
Lines appear before the second and third clicks while the mouse is moved.
1
Triangle is displayed.
1
Perimeter is diplayed.
1
Area is displayed.
1
Angles are displayed.
1
Perimeter, area, and angle measurements are displayed nicely formatted.
1
Median lines are displayed
1
Canvas is reset after the fourth click

Submitting Your Work

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.

  1. From a web browser, go to the Blackboard Course Web Site at courses.goshen.edu.
  2. Click on the link View/Complete Assignment: Lab03.
  3. Under "Assignment Materials," click the Browse button.
  4. Select your ".java" file.
  5. Click the Open button. The full path name of your ".java" file should appear in the File to Attach text field.
  6. Type anything you want in the Comments text box.
  7. Click on the Submit button. The message " The assignment has been updated." should appear.

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.