-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.svelte
77 lines (72 loc) · 1.85 KB
/
App.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<script>
//Currency Converter
//INR to USD
var formatter = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD"
});
let loanAmount = 200000;
let years = 15;
let interestRateInput = 200;
$: interestRate = interestRateInput / 100;
$: totalPayments = years * 12;
$: monthlyInterestRate = interestRate / 100 / 12;
$: monthlyPayment =
(loanAmount *
Math.pow(1 + monthlyInterestRate, totalPayments) *
monthlyInterestRate) /
(Math.pow(1 + monthlyInterestRate, totalPayments) - 1);
$: totalPaid = monthlyPayment * totalPayments;
$: interestPaid = totalPaid - loanAmount;
</script>
<style>
.outputs {
font-size: 20px;
border: solid black 2px;
margin-top: 15px;
text-align: center;
}
</style>
<main class="container">
<div class="row"><h1>Fincalsy: Your one stop solution for all calculations.<br/></h1></div>
<div class="row">
<h1>Mortgage Calculator</h1>
</div>
<div class="row">
<label>Loan Amount</label>
<input
min="1"
bind:value={loanAmount}
placeholder="Enter loan amount"
type="number"
class="u-full-width" />
</div>
<div class="row">
<div class="columns six">
<label>Years</label><input
type="range"
min="1"
max="50"
class="u-full-width"
bind:value={years} />
</div>
<div class="columns six outputs">{years} years</div>
</div>
<div class="row">
<div class="columns six">
<label>Interest Rate</label>
<input
type="range"
min="1"
max="2000"
class="u-full-width"
bind:value={interestRateInput} />
</div>
<div class="columns six outputs">{interestRate.toFixed(2)}%</div>
</div>
<div class="row outputs">
Monthly Payments {formatter.format(monthlyPayment)}
</div>
<div class="row outputs">Total Paid {formatter.format(totalPaid)}</div>
<div class="row outputs">Interest Paid {formatter.format(interestPaid)}</div>
</main>