Assignment #1

Cartesian Distance Calculation

Due: 9/12/03 at 1:00 pm

Write a Java application that will calculate the distance between two points (x1 ,y1) and ( x2,y 2) on a Cartesian coordinate plane using the formula:

d = (( x 1- x2 )2   + ( y1- y 2 )2 )1/2
 

Program requirements:

  1. Keyboard entry of (x 1,y1 ) and (x2 ,y2).
  2. Distance clearly enunciated.
  3. Program should allow multiple distance calculation w/o relaunching.
  4. Java source prologue is extractable using Javadoc utility.
  5. Java source is well commented and extractable using Javadoc.
The program source should be in a file named "Lastname"1.java. (i.e. leeper1.java)

The completed assignment should be sent to [email protected]

It is recommended that you use the JDK 1.2 compiler with Textpad or another editor for this assignment.



The following is a sample execution of an acceptable program:

Please enter an integer x1:> 2

Please enter an integer x2:> 3

Please enter an integer y1:> 8

Please enter an integer y2:> -5

The distance between the points (2,3) and (8,-5)  is:

XX

Would you like the distance between two other points (1-yes, 2-no) :> 1

Please enter an integer x1:> 2

Please enter an integer x2:> 3

Please enter an integer y1:> 8

Please enter an integer y2:> -a

ERROR --- Y2 must be numeric !

Please enter an integer x1:> 2

Please enter an integer x2:> 3

Please enter an integer y1:> 8

Please enter an integer y2:> -5

The distance between the points (2,3) and (8,-5)  is:

XX


 

Would you like to find another GCD (1-yes, 2-no) :> 2

goodbye!