import java.util.Scanner; public class Slope { public static double calculateSlope(int x0, int y0, int x1, int y1) { // avoid dividing by zero if(x1 == x0) { throw new ArithmeticException("Vertical lines can not have a slope"); } return (double)(y1 - y0) / (double)(x1 - x0); } public static void main(String args[]) { Scanner in = new Scanner(System.in); int x0 = in.nextInt(); int y0 = in.nextInt(); int x1 = in.nextInt(); int y1 = in.nextInt(); try { double slope = calculateSlope(x0, y0, x1, y1); System.out.println("The slope of the line is " + slope); } catch (ArithmeticException e) { e.printStackTrace(); String mesg = e.getMessage(); System.out.println(mesg); } } }