Distance - } public void setCoordinates(int x1, int y1, int...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//© A+ Computer Science - www.apluscompsci.com //Name - //Date - //Lab - import java.util.Scanner; import static java.lang.System.*; import static java.lang.Math.*; public class Distance { private int xOne,yOne,xTwo,yTwo; private double distance; public Distance() { setCoordinates(0,0,0,0); distance = 0; } public Distance(int x1, int y1, int x2, int y2) { setCoordinates(x1,y1,x2,y2);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public void setCoordinates(int x1, int y1, int x2, int y2) { xOne = x1; yOne = y1; xTwo = x2; yTwo = y2; } public void calcDistance() { distance = Math.sqrt(((xTwo - xOne)*(xTwo - xOne))+((yTwo - yOne)*(yTwo - yOne))); } public void print( ) { System.out.printf("distance == " + " " + "%.3f\n",distance); System.out.println("\n\n"); } }...
View Full Document

Ask a homework question - tutors are online