Einzelnen Beitrag anzeigen
  #1  
Alt 25.01.2016, 11:03:21
gustav gustav ist offline
Anfänger
 
Registriert seit: Jan 2016
Alter: 33
Beiträge: 3
Lösung einer Gleichung

PHP-Code:
<?php
          
        $a 
$_GET['a_eingabe'];
        
$b $_GET['b_eingabe'];        
        
$c $_GET['c_eingabe'];        
        
        
// Echo-Ausgabe nur zur Kontrolle
        // echo "<b>$a&sdot;x² + $b&sdot;x + $c  = 0</b>";
        
        
$det $b*$b-4*$a*$c;

        if (
$det <0)
        {
            echo 
"Die Gleichung $a&sdot;x² + $b&sdot;x + $c  = 0 hat keine Lösung.";
        }
        elseif (
$det ==0)
        {
            
$loesung round(-$b/(2*$a),2);
            echo 
"Die Gleichung $a&sdot;x² + $b&sdot;x + $c  = 0 hat die Lösung $loesung.";
        }
        elseif (
$det 0)
        {
            
$loesung1 round((-$b+sqrt($det))/(2*$a),2);
            
$loesung2 round((-$b-sqrt($det))/(2*$a),2);
            echo 
"Die Gleichung $a&sdot;x² + $b&sdot;x + $c  = 0 hat die Lösungen $loesung1 und $loesung2.";
        }

        
?>
        <p><a href="mitternacht_eingabe.html">Eine neue Gleichung berechnen?</a></p>
Mit Zitat antworten