Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. public static double getRoot1(double a, double b, double c) {
  2.             double root1;
  3.             String s = "No Real Solution"; 
  4.             if((b*b) - 4*a*c < 0) {
  5.               throw new IllegalArgumentException(s);
  6.             }
  7.             else {
  8.                 root1 = (-b + Math.sqrt((b*b) - 4*a*c))/ (2*a);
  9.             }
  10.             return root1;
  11.             
  12.         }
  13.         public static double getRoot2(double a, double b, double c) {
  14.               double root2;
  15.             String s = "No Real Solution"; 
  16.             if((b*b) - 4*a*c < 0) {
  17.               throw new IllegalArgumentException(s);
  18.             }
  19.             else {
  20.                  root2 = (-b - Math.sqrt((b*b) - 4*a*c))/ (2*a);
  21.             }
  22.             
  23.             return root2;
  24.         }
  25.     
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement