Ledger Nano X - The secure hardware wallet
SHARE
TWEET

quadratic

a guest Apr 5th, 2020 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.lang.Math;
  3.  
  4. public class SwagClass
  5. {
  6.     public static void main(String[] args)
  7.     {
  8. Scanner myScanner = new Scanner(System.in);
  9.        
  10.         System.out.println("Ievadi a vērtību kvadrātvienādojumam, ja nav, ievadi 0");
  11.         int a;
  12.         a = myScanner.nextInt();
  13.        
  14.         System.out.println("Ievadi b vērtību kvadrātvienādojumam, ja nav, ievadi 0");
  15.         int b;
  16.         b = myScanner.nextInt();
  17.        
  18.         System.out.println("Ievadi c vērtību kvadrātvienādojumam, ja nav, ievadi 0");
  19.         int c;
  20.         c = myScanner.nextInt();
  21.        
  22.         double D = Math.pow(b, 2) - 4*a*c;
  23.        
  24.         Double x1 = (-b + Math.sqrt(D)) / (2*a);
  25.         Double x2 = (-b - Math.sqrt(D)) / (2*a);
  26.        
  27.         if (Double.isNaN(Math.sqrt(D)))
  28.         {
  29.             System.out.println("Atbildes nav");
  30.         }
  31.         else
  32.         {
  33.             System.out.println("Tavas saknes vērtības ir " + x1 + " un " + x2);
  34.         }
  35.        
  36.         myScanner.close();
  37.     }
  38.  
  39. }
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
Top