<?php
if (!isset($op))
{
echo "Bitte gib die Anzahl der Noten ein:<br>\n";
echo "<form method=\"post\" action=\"_rechner.php?op=note\">\n";
echo "<input type=\"text\" name=\"a\"><br>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Senden\">\n";
echo "</form>";
}
if ($op == "note")
{
echo "<form method=\"post\" action=\"_rechner.php?op=calc&a=$a\">\n";
for ($i = 1; $i < $a+1; $i++)
{
echo "Die $i. Note:<br>\n";
echo "<input type=\"text\" name=\"note[]\"><br>\n";
}
echo "<input type=\"submit\" name=\"submit\" value=\"Senden\">\n";
echo "</form>\n";
}
if ($op == "calc")
{
$sum = array_sum($note);
$a = count($note);
$durch = number_format($sum/$a,2,",",".");
echo "Dein Notendurchschnitt beträgt ca. ".$durch."<br><br>\n";
echo "<a href=\"_rechner.php\">Nochmal!!!</a>\n";
}
?>