SHARE
TWEET

Untitled

a guest Dec 6th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Scanner s = new Scanner (System.in);
  2.        
  3.         System.out.print("Limit: ");
  4.        
  5.        
  6.         int n = s.nextInt();
  7.         double x1, x2;
  8.         for (int a = 1; a <= n; a++) {
  9.             for (int b = 1; b <= n; b++) {
  10.                 for (int c = 1; c <= n; c++) {
  11.                     System.out.println("a = " + a + " b = " + b + " c = " + c);
  12.                    
  13.                      double d = b*b - 4*a*c;
  14.        if (d<0) {
  15.            System.out.println("No solution");
  16.        }
  17.        else if (d == 0) {
  18.             x1 = -b/(2*a);
  19.            System.out.printf ("x1 = %f\n", x1);
  20.        }
  21.        else if (d>0) {
  22.            x1 = (-b - Math.sqrt(d) )/ (2*a);
  23.            x2 = (-b + Math.sqrt(d))/(2*a);
  24.            System.out.printf("x1 = %f\n", x1);
  25.            System.out.printf ("x2 = %f\n", x2);
  26.        }
  27.                    
  28.                    
  29.                 }
  30.             }
  31.  
  32.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top