Write methods

public static double angle(Point2D.Double p, Point2D.Double q)
public static double slope(Point2D.Double p, Point2D.Double q)

that compute the angle between the x-axis and the line joining two points, measured in degrees, and the slope of that line. Add the methods to the class Geometry. Supply suitable preconditions. Why does it make sense to use a static method in this case?

Complete the following files:



Use the following file:


import java.awt.geom.Point2D;

   This program tests the methods to compute the slope and
   angle of a line.
public class LineTester
   public static void main(String[] args)
      Point2D.Double p = new Point2D.Double(1, 1);
      Point2D.Double q = new Point2D.Double(3, 0);

      System.out.println("Slope: " + Geometry.slope(p, q));
      System.out.println("Expected: -0.5");

      Point2D.Double r = new Point2D.Double(3, -1);

      System.out.println("Angle: " + Geometry.angle(p, r));
      System.out.println("Expected: -45.0");