// This program computes two slopes and prints them. public class SeveralSlopes { public static void main(String[] args) { double s1 = slope(0, 0, 5, 10); double s2 = slope(5, 10, 20, 15); System.out.println("The slopes are " + s1 + " and " + s2); // System.out.println("The slopes are " + slope(0, 0, 5, 10) + " and " + // slope(5, 10, 20, 15)); } // Returns the slope of the line between the given points. // 0 0 5 10 public static double slope(int x1, int y1, int x2, int y2) { double dy = y2 - y1; // 10.0 double dx = x2 - x1; // 5.0 double s = dy / dx; // 2.0 return s; } }