34 lines
1005 B
HTML
34 lines
1005 B
HTML
<!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>
|