Advertisement
WiktoriaRatajczyk

JavaScript1-13

Nov 23rd, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const nr1 = prompt ("Podaj pierwszą wartość");
  2. const nr2 = prompt ("Podaj drugą wartość");
  3. const nr3 = prompt ("Podaj trzecią wartość");
  4.  
  5. if (nr1 > 0 && nr2 > 0 && nr3 > 0)
  6. {
  7.     let delta;
  8.     delta = +nr2 * +nr2 - 4 * +nr1 * +nr3;
  9.    
  10.     if (delta > 0)
  11.     {
  12.         let x1; let x2;
  13.         x1 = -nr2 + delta / 2 * +nr1;
  14.         x2 = -nr2 - delta / 2 * +nr1;
  15.        
  16.         document.write ("X1 wynosi " + x1 + " a x2 wynosi " + x2);
  17.     }
  18.    
  19.     if (delta < 0)
  20.     {
  21.         document.write ("Delta jest mniejsza od 0");
  22.     }
  23.  
  24.     if (delta == 0)
  25.     {
  26.         let x0;
  27.         x0 = -nr2 / 2 * +nr2;
  28.         document.write ("Delta wynosi 0 a x0 jest równy " + x0);
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement