This commit is contained in:
52
01_grundlagen/uebungen/u08_tax-totalprice.html
Normal file
52
01_grundlagen/uebungen/u08_tax-totalprice.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Übung 8: Immer diese Steuern...</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="container py-5">
|
||||
<div class="alert alert-primary">
|
||||
<h2>Übung 8: Immer diese Steuern...</h2>
|
||||
<p>
|
||||
Preise könnten so viel angenehmer sein, wenn die verflixte Mehrwertsteuer nicht wäre. Aber wenn du die
|
||||
Steuer schon selbst zahlen musst, kann dir wenigstens das Ausrechnen des Brutto-Preises jemand abnehmen: JS!
|
||||
Schreibe also ein Programm, das dir den Bruttopreis zu $150 (netto) berechnet und ausgibt — Hinweis: Es
|
||||
sollten $183 sein.
|
||||
</p>
|
||||
<p>Folgende Definitionen steht dir zur Verfügung:</p>
|
||||
<p>
|
||||
<code>
|
||||
'use strict'<br />
|
||||
const TAX_PERCENTAGE = 22<br />
|
||||
let price = 150<br />
|
||||
/* your code here */<br />
|
||||
console.log(totalPrice)<br />
|
||||
</code>
|
||||
</p>
|
||||
</div>
|
||||
<div class="output alert alert-secondary my-3"></div>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
'use strict';
|
||||
const TAX_PERCENTAGE = 22;
|
||||
const TAX_RATE = 1 + TAX_PERCENTAGE / 100; // => 1.22
|
||||
|
||||
const outputEl = document.querySelector('.output');
|
||||
|
||||
const price = 150;
|
||||
|
||||
// const totalPrice = price + (price * TAX_PERCENTAGE) / 100;
|
||||
const totalPrice = price * TAX_RATE;
|
||||
|
||||
console.log(totalPrice);
|
||||
outputEl.textContent = `total price is: $${totalPrice}`;
|
||||
|
||||
/* your code here */
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user