Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
- </head>
- <body>
- <form class="col-lg-6 offset-lg-3">
- <h1>Rechner</h1>
- <div class="form-group">
- <label for="income">Netto-Einkommen</label>
- <input id="income" class="form-control" type="text" value="30000" name="einkommen" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="expenses">Ausgaben pro Jahr</label>
- <input id="expenses" class="form-control" type="text" value="12000" name="ausgaben" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="savings">Sparbetrag pro Jahr</label>
- <input id="savings" class="form-control" type="text" value="18000" name="sparrate" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="networth">Aktuelles Vermögen</label>
- <input id="networth" class="form-control" type="text" value="0" name="vermoegen" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="roi">Jährliche Rendite</label>
- <input id="roi" class="form-control" type="text" value="5" name="rendite" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="withdrawal-rate">Entnahmerate</label>
- <input id="withdrawal-rate" class="form-control" type="text" value="4" name="withdrawal" autocomplete="off">
- </div>
- <input type="button" value="Berechnen">
- <br><br>
- <p id="output"></p>
- </form>
- <script type="text/javascript">
- const button = document.querySelector('input[type="button"]');
- const output = document.querySelector('p#output');
- button.addEventListener('click', calculate);
- function calculate() {
- var income = document.getElementById('income').value;
- var expenses = document.getElementById('expenses').value;
- var savings = document.getElementById('savings').value;
- var networth = document.getElementById('networth').value;
- var roi = document.getElementById('roi').value / 100;
- var withdrawalrate = document.getElementById('withdrawal-rate').value / 100;
- var savingrate = (income - expenses) / income;
- if(withdrawalrate == 0 || savingrate == 0) {
- output.textContent = 'So wird das nichts...';
- }
- else {
- var years = Math.log((((roi * (1 - savingrate) * income) / withdrawalrate) + (savingrate * income)) / ((roi * networth) + (savingrate * income))) / Math.log(1 + roi);
- var years_string = Math.round(years *10)/10;
- var savingrate_string = Math.round(savingrate*100)+'%'
- output.textContent = 'Du kannst in Rente gehen in '+years_string+' Jahren bei einer Sparquote von '+savingrate_string+'.';
- }
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment