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
Charles was supposed to present his PowerPoint slides to his classmates in a classroom, but now he has to present in the auditor
9966 [12]

Answer:

it is c

Explanation:

cus of the long and huge hall of u have in ur school

3 0
3 years ago
Read 2 more answers
Suppose barriers to entry exist in the telecommunications industry. This best describes a _____ market.
melamori03 [73]
The correct answer for the question that is being presented above is this one: "monopolistic." Suppose barriers to entry exist in the telecommunications industry. This best describes a monopolistic market. In a <span>monopolistic market, that specific source of service or good, is being handled by a single company.</span>

4 0
3 years ago
(1) Prompt the user to input an integer between 32 and 126, a float, a character, and a string, storing each into separate varia
cricket20 [7]

Answer:

Following is given the required program. All the steps are described by comments. The sample output for the program is also attached.

I hope it will help you!

Explanation:

5 0
3 years ago
burger hut is trying to decide if it can receive money from the government for providing employees with insurance .
lawyer [7]

Answer:

A cell grows to its full size, The cell copies its DNA

have a great weekends, hopefully it was the right answer!

8 0
3 years ago
The___is a waterproof fabric that is placed around your camera
Zina [86]
Can you help me with homework and the answer is a circle
5 0
3 years ago
Other questions:
  • Which of the following menu commands would you select to make a copy of an open file and rename it?
    15·1 answer
  • When searching the web software programs called fetch a few web pages and then they follow the links on those pages and fetch th
    9·2 answers
  • You are tasked with accumulating survey data on a web page and are responsible for it being free from dirty data once you close
    11·1 answer
  • Need help please. this effect my technology
    15·1 answer
  • java Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins w
    11·1 answer
  • I need help picture above
    14·2 answers
  • What constructs break or bend the normal Syntax patterns of scheme?
    15·1 answer
  • HEPME <br> ZOOM<br> IN <br> STOP<br> GIVIJG<br> ME <br> LINKS <br> !!
    9·1 answer
  • How do you fix this!!!!
    5·1 answer
  • What is a personal data?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!