1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
defon
3 years ago
12

Add the following method to the Point class: public double distance(Point other) Returns the distance between the current Point

object and the given other Point object. The distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates. In other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 - x1)2 (y2 - y1)2. Two points with the same (x, y) coordinates should return a distance of 0.0.
public class Point {
int x;
int y;
// your code goes here
}
Computers and Technology
1 answer:
GaryK [48]3 years ago
3 0

Answer:

public class Point

{

  public int x;

  public int y;

  Point(int x,int y)

  {

      this.x=x;

      this.y=y;

  }

  public static void main(String[] args)

  {

      Point p1=new Point(-2,3);

      Point p2=new Point(3,-4);

      System.out.println("distance:"+distance(p1,p2));

 }

  private static double distance(Point p1,Point p2)

  {

      return Math.sqrt(Math.pow(p2.x-p1.x, 2)+Math.pow(p2.y-p1.y, 2));

  }

}

Explanation:

The java program defines the Point class and the public method 'distance' to return the total distance between the two quadrants passed to it as arguments (they are both instances of the Point class).

You might be interested in
What is the simplest way to permanently get rid of an unwanted file? A. Cancel the file. B. Go to the Start menu and then delete
Morgarella [4.7K]
Go to the Start menu and then delete the file <span>is the simplest way to permanently get rid of an unwanted file</span>
5 0
4 years ago
But this time use 16 kib pages instead of 4 kib pages. what would be some of the advantages of having a larger page size? what a
uranmaximum [27]

Here are the advantages and disadvantages of larger paper size: 

Advantages: 

Reduces minor page faults. 

Disadvantages: 

There will be a decrease in the number of frames. 

There will be an increase number of page faults. 

<span>Waste of more space with the internal fragmentation.</span>

6 0
4 years ago
How will you configure those computer hardware peripherals​
almond37 [142]

Answer:

i dont

Explanation:

know sorry tenks thankyou

8 0
2 years ago
What does the opacity effect to do
azamat
Opacity is the condition of lacking transparency. Opacity is opaqueness.
3 0
3 years ago
Read 2 more answers
JAVA Write code which prints every number from 1 to 20 a number of times equal to the number itself (e.g. one 1, two 2's...). Ev
kvasek [131]

I've included my code in the picture below. Best of luck.

3 0
3 years ago
Other questions:
  • A School is interested in computerizing their students&lt;br /&gt;grading system.&lt;br /&gt;I Marks Grade&lt;br /&gt;150-100 A&
    11·1 answer
  • The input stream of a stack is a list of all the elements we pushed onto the stack, in the order that we pushed them. If the inp
    9·1 answer
  • Which acronym describes technology in which all or most of a deviceâs electronic circuitry is on a single microchip?
    12·1 answer
  • Which of the following types of copyright license is most appropriate if you write a novel and would like to post it online for
    11·1 answer
  • Sam needs to create a spreadsheet for his coworkers. They will need to follow across a long row of data. Sam would like to make
    8·2 answers
  • In checking the digital signature, the verifier ____. a. decrypts the digital signature it received with the supplicant public k
    13·1 answer
  • Modifying the column widths usually is done last because other formatting changes may affect the size of data in the cells in th
    10·1 answer
  • Why Do You Need to Set Goals for a LinkedIn Automation Campaign?
    15·1 answer
  • NO LINKS Please
    8·2 answers
  • Amber is a hacker who steals information when people enter their personal details on specific websites. She intercepts the publi
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!