Advertisement
duc-phan

Untitled

Dec 1st, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public class Quadratic {
  2.     public static double root1(double a, double b, double c) {
  3.         double determinant = determinant(a, b, c);
  4.         return (-b + Math.sqrt(determinant)) / (2*a);
  5.     }
  6.     public static double root2(int a, int b, int c) {
  7.         double determinant = determinant(a, b, c);
  8.         return (-b - Math.sqrt(determinant)) / (2*a);
  9.     }
  10.     private static double determinant(double a, double b, double c) {
  11.         return b*b - 4*a*c;
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement