IN KA 1 AUFGABE echo "

Portokosten

"; function holePortokosten(float $gewicht):int { $porto = 0.0; if ($gewicht > 0.0 && $gewicht < 1.0){ $porto = 150; } elseif ($gewicht >= 1.0 && $gewicht < 5.0){ $porto = 540; } elseif ($gewicht >= 5.0 && $gewicht <= 25.0){ $porto = 1290; } else { $porto = -1; } return $porto; } // ######## // # TEST # // ######## $gewicht = 1000; $gewicht_f = number_format($gewicht, 2, ",", "."); $porto = holePortokosten($gewicht); if ($porto == -1){ echo "

Das Gewicht $gewicht ist nicht zulässig. Es ist zu Schwer

"; } else { $porto_euro = $porto / 100; $porto_euro_f = number_format($porto_euro, 2, ",", "."); echo "

Ihr Paket mit $gewicht kg kostet $porto_euro_f

"; } // SG 2 echo "

Quersumme

"; // 37652 => Quersumme = 3+7+6+5+2 = 23 // UML. berechneQuersumme(zahl: int): int $qr_zahl = 37652; echo "

Zahl: $qr_zahl

"; function berechneQuersumme(int $zahl):int { $quersumme = 0; while ($zahl > 0){ $quersumme += $zahl % 10; $zahl = intdiv($zahl, 10); } return $quersumme; } echo "Berechnete Quersumme: " + berechneQuersumme($qr_zahl); ?>