Added broetchenrechner
This commit is contained in:
34
uebung3/broetchenrechner.html
Normal file
34
uebung3/broetchenrechner.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Brötchenrechner</title>
|
||||
</head>
|
||||
<body>
|
||||
<label for="broetchen">Anzahl der Brötchen: </label>
|
||||
<input id="broetchen" name="broetchen" type="number">
|
||||
<button id="calcbutton">Berechnen</button>
|
||||
|
||||
<script>
|
||||
let btn = document.getElementById("calcbutton");
|
||||
let field = document.getElementById("broetchen");
|
||||
|
||||
btn.addEventListener("click", calculate);
|
||||
|
||||
function calculate() {
|
||||
let anzbroetchen = field.value;
|
||||
|
||||
let result = anzbroetchen * 0.55;
|
||||
if (anzbroetchen > 10) {
|
||||
let rabatt = result / 100 * 10;
|
||||
result -= rabatt;
|
||||
}
|
||||
alert("Die Brötchen kosten " + result + "€");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user