Question: JAVA PROGRAM Create an Location class that has 3 private attributes: name: String x: int y: int And the following public methods: GetDistance(Location a): double

 JAVA PROGRAM Create an Location class that has 3 private attributes:

JAVA PROGRAM

Create an Location class that has 3 private attributes: name: String x: int y: int And the following public methods: GetDistance(Location a): double ReadCoordinates(): void Plus getters and setters for the attributes. ReadCoordinates() reads x and y coordinates from keyboard and assigns them to class attributes using setters. Check sample output for details. GetDistance(Location a) gets another Location as parameter, and returns the euclidean distance between itself and the given location. In WhereToGo, main(). you should first initialize home location using setters to X and Y (0, 0) and set its name to "Home". Then, from keyboard, read how many locations you need to test for. Then, read that many locations, find the closest in terms of GetDistanceQ metric and print the closest given location. You should initialize the temporary locations using ReadCoordinates(). A sample output is provided. Sample Outputs: How many places will we try3 Name: NilgunAbla X Coordinate: 2 Y Coordinate: 5 Name: OrtaDunya X Coordinate: 20 Y Coordinate: 40 Name: Tunali X Coordinate: 80 Y Coordinate: 120 We should go to NilgunAbla

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!