Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

Who will implement and maintain the project after launch?

Answered: 1 week ago

Question

Determine the amplitude and period of each function.

Answered: 1 week ago