Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA: Exercise 1.5: Create an array of 10 XYPoints in your main function with random X,Y coordinates between 0 and 20. Add a distanceToAllPoints

IN JAVA: Exercise 1.5: Create an array of 10 XYPoints in your main function with random X,Y coordinates between 0 and 20. Add a distanceToAllPoints function that calculates the distance between each pair of points in the array and prints it to the console. explain why you created the function in the place that you did and why you chose those arguments.

image text in transcribed

Let's now see how this can work with a group of objects in an array: class XYPoint double x; double y; public vold printDistanceO double d-Math.sqrt(x*x System.out.println(d); + y*y); public class Main public static void main(String[] argv) [ Make an instance of the object with the new operator: XYPoint[] p new XYPoint[3]; p]new XYPointO; First point. Second one Third. p[1] new XYPointO; p[2]-new XYPointO; for Cint i-0;

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions