-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1960 from SaiTejaswaniBikkasani/add-compound-inte…
…rest-calculator Added Compound Interest Calculator
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
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,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Compound interest calculator</title> | ||
<link rel="stylesheet" href="style.css"> | ||
<link rel="manifest" href="manifest.json"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Compound Interest Calculator</h1> | ||
<div class="input-values"> | ||
<div class="elements"> | ||
<label>Principal Amount:</label> | ||
<input type="number" min="0" class="js-principal"><br> | ||
</div> | ||
<div class="elements"> | ||
<label>Annual Interest Rate (%):</label> | ||
<input type="number" min="0" class="js-interest-rate"><br> | ||
</div> | ||
<div class="elements"> | ||
<label>Number of Years:</label> | ||
<input type="number" min="0" class="js-years"><br> | ||
</div> | ||
<button type="submit" class="js-submit">Calculate</button> | ||
<div class="js-result result" style="display: none"></div> | ||
</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,9 @@ | ||
{ | ||
"name": "Compound Interest Calculator", | ||
"short_name": "InterestCalc", | ||
"description": "A simple compound interest calculator.", | ||
"start_url": "index.html", | ||
"display": "standalone", | ||
"background_color": "#ffffff", | ||
"theme_color": "#4CAF50" | ||
} |
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,24 @@ | ||
function compoundInterest() { | ||
const principalAmount = document.querySelector('.js-principal').value; | ||
const interestRate = document.querySelector('.js-interest-rate').value; | ||
const years = document.querySelector('.js-years').value; | ||
|
||
document.querySelector('.js-result').style.display = 'block'; | ||
|
||
let calculatedValue; | ||
|
||
console.log(principalAmount); | ||
|
||
if(principalAmount !== '' && interestRate !== '' && years !== ''){ | ||
calculatedValue = principalAmount * Math.pow((1 + interestRate / 100), years) - principalAmount; | ||
|
||
document.querySelector('.js-result').innerHTML = `Compound Interest: ₹${calculatedValue.toFixed(2)}`; | ||
}else { | ||
document.querySelector('.js-result').innerHTML = 'Please enter valid input values'; | ||
} | ||
} | ||
|
||
document.querySelector('.js-submit') | ||
.addEventListener('click', () => { | ||
compoundInterest(); | ||
}); |
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,52 @@ | ||
.container{ | ||
width: 600px; | ||
height: 300px; | ||
background-color: #f9f9f9; | ||
margin: 0 auto; | ||
} | ||
input{ | ||
border-radius: 5px; | ||
border: 1.5px solid black; | ||
width: 200px;; | ||
padding: 6px; | ||
margin-left: 10px; | ||
|
||
} | ||
.elements{ | ||
margin-top: 15px; | ||
} | ||
label{ | ||
font-family: Arial; | ||
font-size: 15px; | ||
font-weight: bold; | ||
} | ||
button{ | ||
padding: 7px 30px; | ||
text-align: center; | ||
font-size: 15px; | ||
border-radius: 5px; | ||
border: none; | ||
background-color: green; | ||
color: white; | ||
margin-top: 30px; | ||
margin-left: 200px; | ||
cursor: pointer; | ||
font-weight: bold; | ||
} | ||
button:hover{ | ||
background-color: #e6e6e6; | ||
color: black | ||
} | ||
.input-values{ | ||
margin-left: 20px; | ||
} | ||
h1{ | ||
text-align: center; | ||
} | ||
.result{ | ||
padding-top: 10px; | ||
font-size: 17px; | ||
color: #8A2BE2; | ||
font-weight: bold; | ||
text-align: center; | ||
} |