Android examples for java.lang:Math Formula
Formula to calculate slope
import java.text.DecimalFormat; public class Main{ private static double result; public static double slope(double x1, double x2, double y1, double y2) throws InvalidInputException { if (x2 != x1) { result = ((y2 - y1) / (x2 - x1)); return result; } else {//from w w w . jav a 2 s .co m throw new InvalidInputException(); } } }