Answered step by step
Verified Expert Solution
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
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 NilgunAblaStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started