- Umbennung von dem ordner wo die vorlage liegt
- Aufgabe vom 9.10.24
This commit is contained in:
35
progp/24-10-9/bmi.php
Normal file
35
progp/24-10-9/bmi.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>BMI - Body Mass Index</h1>
|
||||
<h2>Daten Eingabe</h2>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$gewicht = $_REQUEST['gewicht'];
|
||||
$groesse = $_REQUEST['groesse'];
|
||||
|
||||
$bmi = $gewicht / (($groesse/100) ** 2);
|
||||
|
||||
echo "<div>";
|
||||
echo "<p>Ihr Gewicht: ". $gewicht. " kg</p>";
|
||||
echo "Ihre Größe: ". $groesse. " cm</p>";
|
||||
echo "<p><strong>Ihr BMI: ". $bmi. "</strong></p>";
|
||||
|
||||
if ($bmi < 18.5) {
|
||||
echo "<p>Sie sind untergewichtig.</p>";
|
||||
} elseif ($bmi >= 18.5 && $bmi < 25) {
|
||||
echo "<p>Sie sind normalgewichtig.</p>";
|
||||
} elseif ($bmi >= 25 ) {
|
||||
echo "<p>Sie sind übergewichtig.</p>";
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
55
progp/24-10-9/bmi_form.html
Normal file
55
progp/24-10-9/bmi_form.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>BMI Rechner</title>
|
||||
<style>
|
||||
.unterdiv {
|
||||
/*border: 1px solid silver;
|
||||
margin: 4px 0; Aussenabstand oben/unten 4px */
|
||||
padding: 4px; /* Innenabstand überall 4px */
|
||||
background-color: lightgray;
|
||||
}
|
||||
label {
|
||||
display: inline-block;
|
||||
width: flex;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>BMI - Body Mass Index</h1>
|
||||
<h2>Daten Eingabe</h2>
|
||||
<form action="bmi.php">
|
||||
<div>
|
||||
<div class="unterdiv">
|
||||
<label for="gw">Gewicht in kg: </label>
|
||||
<input
|
||||
id="gw"
|
||||
name="gewicht"
|
||||
title="Bitte geben sie ihr Geewicht in kg ohne Kommastellen ein!"
|
||||
placeholder="99"
|
||||
type="number"
|
||||
min="20"
|
||||
max="700"
|
||||
required
|
||||
>
|
||||
</div>
|
||||
<div class="unterdiv">
|
||||
<label for="gr">Größe in cm:</label>
|
||||
<input
|
||||
id="gr"
|
||||
name="groesse"
|
||||
title="Bitte geben sie ihre Größe in cm ohne Kommastellen ein!"
|
||||
placeholder="180"
|
||||
min="100"
|
||||
max="250"
|
||||
type="number"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button>BMI berechnen</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
43
progp/24-10-9/verzweigungen.php
Normal file
43
progp/24-10-9/verzweigungen.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Kontrollstrukturen: Verzweigungen</title>
|
||||
<style>
|
||||
.nok {
|
||||
color: red;
|
||||
}
|
||||
.ok {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Datei: verzweigungen.php -->
|
||||
<h2>einfache Verzweigungen</h2>
|
||||
<?php
|
||||
$geschw = 80;
|
||||
// einfache verzweigung mit (if)
|
||||
if ($geschw > 80) {
|
||||
echo "<p class='nok'>zu schnell</p>";
|
||||
}
|
||||
echo "<h2>zweife Verzweigungen (if ... else)</h2>";
|
||||
// zweifache verzweigung mit (if .. else)
|
||||
if ($geschw > 80) {
|
||||
echo "<p class='nok'>zu schnell</p>";
|
||||
} else {
|
||||
echo "<p class='ok'>OK</p>";
|
||||
}
|
||||
echo "<h2>dreifache Verzweigungen (if ... elseif ... else)</h2>";
|
||||
// dreifache verzweigung mit (if.. elseif.. else)
|
||||
if ($geschw < 60) {
|
||||
echo "<p class='nok'>zu schnell</p>";
|
||||
} elseif ($geschw > 130) {
|
||||
echo "<p class='nok'>zu langsam</p>";
|
||||
} else {
|
||||
echo "<p class='ok'>OK</p>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user