Distance - } public String determineClosest( ) { double...

Info iconThis preview shows pages 1–2. 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 x1,y1,x2,y2; public Distance() { x1 = 0; y1 = 0; x2 = 0; y2 = 0; } public Distance(int xOne, int yOne, int xTwo, int yTwo) { x1 = xOne; y1 = yOne; x2 = xTwo; y2 = yTwo; } public void setCoordinates(int xOne, int yOne, int xTwo, int yTwo) { x1 = xOne; y1 = yOne; x2 = xTwo; y2 = yTwo;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public String determineClosest( ) { double distanceA = 0.0, distanceB = 0.0; distanceA = Math.sqrt((x1-0.0)*(x1-0.0)+(y1-0.0)*(y1-0.0)); distanceB = Math.sqrt((x2-0.0)*(x2-0.0)+(y2-0.0)*(y2-0.0)); String result=""; if (distanceA > distanceB) return "" + "B is closer to (0,0)." + "\n\n"; if (distanceB > distanceA) return "" + "A is closer to (0,0)." + "\n\n"; return result; } public String toString() { return ""; } }...
View Full Document

Page1 / 2

Distance - } public String determineClosest( ) { double...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online