Advertisement
Adiquus

zad1 php

Apr 17th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5.     <form method="post">
  6.         A= <input name="a" /></br>
  7.         B= <input name="b" /></br>
  8.         C= <input name="c" /></br>
  9.         <input type="submit" value="Rozwiąż równanie" />
  10.     </form>
  11. <?php
  12.     $a = @$_POST['a'];
  13.     $b = @$_POST['b'];
  14.     $c = @$_POST['c'];
  15.    
  16.     if($a==null || $b==null || $c==null || $a==0) {echo "Wprowadź poprawne dane";}
  17.         else{
  18.             $a = @$_POST['a'];
  19.             $b = @$_POST['b'];
  20.             $c = @$_POST['c'];
  21.             echo "a = $a<br>b = $b<br>c = $c";
  22.    
  23.             $delta=pow($b,2)-(4*$a*$c);
  24.            
  25.             echo "<br>Delta równania wynosi $delta";
  26.            
  27.         if($delta<0){
  28.             echo "<br>Funkcja nie posiada pierwiastków.";
  29.             }
  30.         else if($delta>0){
  31.             $x1=(-$b+sqrt($delta))/(2*$a);
  32.             $x2=(-$b-sqrt($delta))/(2*$a);
  33.             echo "<br>x<sub>1</sub> = $x1 <br> x<sub>2</sub> = $x2";
  34.             }
  35.         else {
  36.             $x=-$b/(2*$a);
  37.             echo "<br>x<sub>1</sub> = $x";
  38.             }
  39.         }
  40. ?>
  41.  
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement