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
2 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]2 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
A. Calculate the diffusion coefficient for magnesium in aluminum at 450°C.
SIZIF [17.4K]

Answer:

a) D = 4.88 * 10^(-14) m^2 / s

b)   <em>t </em>= 1.1 hr

Solution:

a) Magnesium in Aluminum diffusion:

D = Do * exp(-Qd / RT)

  =  (1.2 * 10^(-4) m^2 / s) * exp ( - 130,000 / 8.31 * 723.15)

  = 4.88 * 10^(-14) m^2 / s

D = 4.88 * 10^(-14) m^2 / s

b) The composition remains same at say the distance Xo:

(Cx - Co) / (Cs - Co) = Constant

Xo^2 / D_{550} * <em>t </em>= Xo^2 / D_{450} * 15

D_{550} * <em>t </em>= D_{450} * 15

(1.2 * 10^(-4) m^2 / s) * exp ( - 130,000 / 8.31 * 723.15) * <em>t</em>

(4.88 * 10^(-14) m^2 / s) * 15

by, solving for <em>t </em>we get:

 <em>t </em>= 1.1 hr

So, the time required is 1.1 hr.

5 0
2 years ago
________ software provides a means of sharing, distributing, and searching through documents by converting them into a format th
Alexus [3.1K]
The answer to this question is Document Management Software.

Document Management Software or DMS is a computer system or software that is used to store, share, manage, and distribute documents by converting paper based documents into an electronic image that can be viewed by any user. The converting of documents is through the use of a scanner, and the document management software will enable the users to manage the electronic documents or data.
3 0
3 years ago
What does configsys mean​
Delvig [45]

Answer:

Definition - What does CONFIG. ... SYS is a configuration file on DOS systems. It is a text file that contains the settings and commands to load drives in a DOS system. This is a primary configuration file for OS/2 and DOS OS. This file was introduced in DOS and is replaced for 32-bit Windows versions with CONFIG.

Explanation:

6 0
3 years ago
Constructive criticism is intended as a possible solution.
wlad13 [49]

Answer:

True

Explanation:

Constructive criticism is a comment that cuts down on someone, but in an influencing way.

Example: Let's ask him to be more careful the next time he buys fish.

7 0
2 years ago
Name the major types of computer systems from slowest to fastest. ​
Vadim26 [7]

Answer:

Cache is the fastest and most expensive, RAM is slower and less expensive, and virtual memory is the slowest and least expensive type.

Explanation:

3 0
2 years ago
Other questions:
  • Nancy would like to configure an automatic response for all emails received while she is out of the office tomorrow, during busi
    13·2 answers
  • Which of the following is needed if a computer with the IP address 172.31.210.10/24 wants to communicate with a computer with th
    5·1 answer
  • Which of the following Internet protocols is used to request and send pages and files on the World Wide Web?
    15·1 answer
  • Compare and contrast inertial confinement with thermonuclear reactors.
    7·1 answer
  • A byte contains how many bits? Question 3 options:
    13·2 answers
  • When entering data in Access if the data is entered using an Access form, that data is stored in a table or tables. TRUE FALSE
    12·1 answer
  • If you do not clean your hardware on a regular basis, which of these is most likely to be a problem?
    11·1 answer
  • In a _____, there is no skipping or repeating instructions. A. iteration B. sequence C. selection D. conditional
    10·1 answer
  • Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
    8·1 answer
  • balance exercises used for introducing balance training should initially involve little joint motion and improve what type of co
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!