Java examples for Algorithm:Formula
Quadratic Function
public class Quadratic { public static void main(String args[]) { double b = 20.0; double c = 5.0; double dis = b * b - (4 * c); double sq = Math.sqrt(dis); double root1 = (-b + sq) / 2.0; double root2 = (-b - sq) / 2.0; System.out.println(root1 + " " + root2); System.out.println(Math.sqrt(2) * Math.sqrt(2)); if ((int) (Math.sqrt(2) * Math.sqrt(2)) == 2) { System.out.println("prin"); }/* w ww . j a v a 2 s . c om*/ } }