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
Absolute dating can provide us with the age of a rock within a range of 100 years of accuracy.
jasenka [17]
The answer to this is true!
6 0
4 years ago
How can you begin networking online? What’s step one?
pav-90 [236]

Answer:

Step 1: Establish your digital presence by building out your profile. ...

Step 2: Find people to connect with by joining LinkedIn groups. ...

Step 3: Engage by posting content and talking to industry influencers. ...

Step 4: Repeat until you amass a strong following.

Explanation:

3 0
2 years ago
What are examples of processing large data using web technologies
Mkey [24]
Sequence flow
message flow
associated
any web designer that uses CSS3 + HTML5 will be up to date on web technology
7 0
4 years ago
Read 2 more answers
Define the following BASIC terms:<br> 1. Keywords<br> 2. Constants<br> 3.Variables
Mamont248 [21]

Answer:

Explanation:

  1. Keywords: Keywords are those words which have special meanings in QBASIC. Keywords are formed by using characters of QBASIC characters set. Keywords are statements, commands, functions (built in functions) and names of operators. The keywords are also called Reserved Words. Some reserved words are CLS, REM, INPUT, LET, PRINT, FOR, DO, SELECT, ASC, SQR, LEN, and INT.
  2. Constants: They are divided into:
  • Numeric constants: include all numbers (real, integer, not real,...)
  • Character constants: include all character sete (letters, digits, symbols) between two double quotation marks e.g. "BASIC", "the width is 83" etc.

   3. Variables: A variable is a name which can hold or contain a value.

Hope this helps!!

8 0
4 years ago
Suppose the ESPN website uses 8-bit unsigned integers to store how many points a team has scored in
sasho [114]
The answer is 255(base 10). Correct me if I’m wrong!
7 0
3 years ago
Other questions:
  • Machine language is made up of which following codes
    11·1 answer
  • Robots can obtain data from the environment, store the data as knowledge, and modify their behavior
    10·1 answer
  • Mike wants to capture some images of his application as it appears on the screen. In order to do this, Mike needs to know how to
    6·1 answer
  • Convert 15 from decimal to binary. Show your work.
    14·1 answer
  • Why should a linked list node be separate from the element stored on the list?
    5·1 answer
  • Use the Windows ________ to check on a nonresponsive program. Select one: A. Backup utility B. Task Manager C. System Restore D.
    10·1 answer
  • Julio receives many emails from a healthcare site. He finds them useful, and he wants to save them all in a folder. How can he a
    12·1 answer
  • Create a parent class called Shape with width and height parameters of type double and a function that returns the area of the s
    12·1 answer
  • Write a python program to calculate the sum of numbers from 1 to 20 which is divisible by 3.
    12·2 answers
  • What is the shortcut key to create a new desktop ​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!