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
When spraying pesticide wear and protective eyeglass​
exis [7]
Ummmmmmmmmmmmmmmmmmmmm ok
6 0
3 years ago
Read 2 more answers
What number is represented as a binary code of 101110
mariarad [96]

Answer:

46 i think

Explanation:

sorry if thats wrong

4 0
2 years ago
Read 2 more answers
If I wanted to include a picture of a dog in my document, I could use _____. SmartArt WordArt clip art AutoCorrect
Taya2010 [7]

Answer:

clip art / smart art

Explanation:

6 0
3 years ago
As Juan sat in his biology lab, his instructor was droning on about the techniques of vivisection. Juan kept thinking about the
MaRussiya [10]

Answer:

attending

Explanation:

7 0
3 years ago
What are the top and side margins for a letter typed in standard format?
BabaBlast [244]
Should be 1’ on each side
4 0
3 years ago
Other questions:
  • Carson's supervisor has asked him to review a variety of portable computers for possible purchase for their company's employees.
    13·1 answer
  • You resurrected an old worksheet. It appears to contain most of the information that you need, but not all of it. Which step sho
    5·1 answer
  • How can i promote netiquette??​
    10·1 answer
  • Assume that strikeCounter has already been declared to be a "pointer to int". Assume further that strikeCounter has been initial
    5·1 answer
  • True or false? The following deterministic finite-state automaton recognizes the set of all bit strings such that the first bit
    7·1 answer
  • Complete the method, print Multiples(), that takes in a positive integer n, and another positive integer, max. Print out all the
    15·1 answer
  • PLEASE HELP!!!!!!!!!
    8·1 answer
  • What is the<br> binary code<br> for<br> "DMS"?
    8·1 answer
  • How would a barcode reader be used in a healthcare industry?​
    6·1 answer
  • When network traffic is encrypted, it is invisible and its content and purpose are masked.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!