Homework #3: LineLength.
50 points, due 11/9/2000 at the beginning of class.

Create an Java applet that will draw a line from coordinates that the user chooses.

The user will be asked for four integers via Input Dialog boxes. The input dialog boxes should display what numbers have already been selected by the user as they ask for the next one.

A right triangle will be drawn, linking the coordinates that the user specified, as well as the coordinates for each corner of the triangle.

In addition, the length of the line will be displayed in the status bar of the applet window. You must use your own programmer-defined method to calculate the length of the line.

Think of the user when designing the Dialog Boxes: is it obvious to the user what he/she is supposed to do? Is it obvious what the items displayed in the applet window are for? Use proper style conventions in your source code.

Suggestions & Hints:

  1. The overall java program will be an applet, so be sure to import the necessary classes.
  2. The method to calculate the length of the line can use the Pythagorean theorem, which states that the two sides of a right triangle squared and summed equals the square of the hypotenuse. Be careful, however: you'll need to get a double-type value returned from the method.
  3. Can't get started? Look at sample applets that we have done in class. Recall the "drawLine" and "drawString" methods we have seen previously.

Turn in a printout of your source code and a diskette with the java file on it. Name the Java program with your last name and first initial and the number "3". Capitalize the first letter of your last name and the first initial. EX: BookA3.java

Grading criteria:

1. does it compile & run?
15
2. correct processing of the information
27
3. user-friendliness: good labeling in the dialog boxes and applet window
5
4. program source code is commented, logically laid out, and follows style conventions
5
5. files properly labeled
3
Bonus points available:
Make sure that the lines never write over any of the text
Set the hypotenuse length to only show three decimal places

5
2
TOTAL POINTS POSSIBLE:
50
+7

 

 
syllabus | calendar (day) | calendar (evening) | grades
DSMIS Dept. | SLU School of Business | Saint Louis University
 

all rights reserved. copyright 2000, Ann Book