-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Finance Calculator</title> | ||
<link rel="shortcut icon" href="favicon_io/android-chrome-192x192.png" type="image/x-icon"> | ||
<link rel="apple-touch-icon" sizes="180x180" href="favicon_io/apple-touch-icon.png"> | ||
<link rel="icon" type="image/png" sizes="32x32" href="favicon_io/favicon-32x32.png"> | ||
<link rel="icon" type="image/png" sizes="16x16" href="favicon_io/favicon-16x16.png"> | ||
<link rel="manifest" href="/site.webmanifest"> | ||
<link rel="stylesheet" href="style.css"> | ||
|
||
</head> | ||
|
||
<body> | ||
<div class="container card"> | ||
<h1>Finance Calculator</h1> | ||
|
||
<!-- Future Value Calculation --> | ||
<div class="calculator" id="investment-calculator"> | ||
<h2>Future Value of Investment</h2> | ||
<label for="investment-principal">Principal ($):</label> | ||
<input type="number" id="investment-principal" step="0.01"> | ||
<label for="investment-rate">Annual Interest Rate (%):</label> | ||
<input type="number" id="investment-rate" step="0.01"> | ||
<label for="investment-years">Number of Years:</label> | ||
<input type="number" id="investment-years"> | ||
<button onclick="calculateFutureValue()">Calculate</button> | ||
<p id="investment-result"></p> | ||
</div> | ||
|
||
<!-- Monthly Payment Calculation --> | ||
<div class="calculator" id="loan-calculator"> | ||
<h2>Monthly Loan Payment</h2> | ||
<label for="loan-principal">Principal ($):</label> | ||
<input type="number" id="loan-principal" step="0.01"> | ||
<label for="loan-rate">Annual Interest Rate (%):</label> | ||
<input type="number" id="loan-rate" step="0.01"> | ||
<label for="loan-years">Loan Term (Years):</label> | ||
<input type="number" id="loan-years"> | ||
<button onclick="calculateMonthlyPayment()">Calculate</button> | ||
<p id="loan-result"></p> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function calculateFutureValue() { | ||
const principal = document.getElementById("investment-principal").value; | ||
const annualRate = document.getElementById("investment-rate").value; | ||
const years = document.getElementById("investment-years").value; | ||
|
||
// Validate if any field is empty | ||
if (!principal || !annualRate || !years) { | ||
document.getElementById("investment-result").textContent = "Please fill in all fields."; | ||
return; | ||
} | ||
|
||
const principalValue = parseFloat(principal); | ||
const annualRateValue = parseFloat(annualRate) / 100; | ||
const yearsValue = parseInt(years); | ||
|
||
const futureValue = principalValue * Math.pow((1 + annualRateValue), yearsValue); | ||
document.getElementById("investment-result").textContent = `Future Value: $${futureValue.toFixed(2)}`; | ||
} | ||
|
||
function calculateMonthlyPayment() { | ||
const principal = document.getElementById("loan-principal").value; | ||
const annualRate = document.getElementById("loan-rate").value; | ||
const years = document.getElementById("loan-years").value; | ||
|
||
// Validate if any field is empty | ||
if (!principal || !annualRate || !years) { | ||
document.getElementById("loan-result").textContent = "Please fill in all fields."; | ||
return; | ||
} | ||
|
||
const principalValue = parseFloat(principal); | ||
const annualRateValue = parseFloat(annualRate) / 100; | ||
const yearsValue = parseInt(years); | ||
|
||
const monthlyRate = annualRateValue / 12; | ||
const numberOfPayments = yearsValue * 12; | ||
const monthlyPayment = (principalValue * monthlyRate * Math.pow((1 + monthlyRate), numberOfPayments)) / | ||
(Math.pow((1 + monthlyRate), numberOfPayments) - 1); | ||
|
||
document.getElementById("loan-result").textContent = `Monthly Payment: $${monthlyPayment.toFixed(2)}`; | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters