# Distance - public String determineClosest double distanceA...

This preview shows pages 1–2. Sign up to view the full content.

//© 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;

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

View Full Document
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

## This note was uploaded on 11/11/2011 for the course C++ comp122 taught by Professor N/a during the Spring '07 term at Cy-Fair College.

### Page1 / 2

Distance - public String determineClosest double distanceA...

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

View Full Document
Ask a homework question - tutors are online