forked from Rakesh9100/CalcDiverse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Savings Goal Calculator (Rakesh9100#1572)
- Loading branch information
Showing
5 changed files
with
167 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,27 @@ | ||
# <p align="center">Savings Goal Calculator</p> | ||
|
||
## Description :- | ||
|
||
This calculator helps you determine how much you need to save each month to reach your savings goal. By providing the total savings goal, current savings, and the time period (in months), the calculator computes the required monthly savings to achieve the goal. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Formula Used :- | ||
|
||
The formula for calculating the required monthly savings is: | ||
|
||
Monthly Savings = (Savings Goal − Current Savings) / Time Period | ||
|
||
Where: | ||
|
||
Savings Goal is the total amount you want to save. | ||
Current Savings is the amount you have already saved. | ||
Time Period is the number of months you plan to save. | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/user-attachments/assets/658fdabe-f5d0-4b6d-8ad2-c7bcd23fcf04) |
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,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Savings Goal Calculator</title> | ||
</head> | ||
|
||
<body> | ||
<div class="calculator-container"> | ||
<h1>Savings Goal Calculator</h1> | ||
<div class="input-container"> | ||
<label for="goalAmount">Savings Goal Amount (INR):</label> | ||
<input type="number" id="goalAmount" required> | ||
</div> | ||
<div class="input-container"> | ||
<label for="currentSavings">Current Savings (INR):</label> | ||
<input type="number" id="currentSavings" required> | ||
</div> | ||
<div class="input-container"> | ||
<label for="timePeriod">Time Period (Months):</label> | ||
<input type="number" id="timePeriod" required> | ||
</div> | ||
<button type="button" onclick="calculateSavings()">Calculate</button> | ||
<div class="result-container"> | ||
<div id="result">Monthly Savings Required: <span id="savingsResult" class="red">₹0.00</span></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,20 @@ | ||
function calculateSavings() { | ||
const goalAmount = parseFloat(document.getElementById('goalAmount').value); | ||
const currentSavings = parseFloat(document.getElementById('currentSavings').value); | ||
const timePeriod = parseInt(document.getElementById('timePeriod').value); | ||
|
||
if (isNaN(goalAmount) || isNaN(currentSavings) || isNaN(timePeriod)) { | ||
document.getElementById('result').textContent = 'Please fill in all fields correctly.'; | ||
return; | ||
} | ||
|
||
if (goalAmount <= currentSavings) { | ||
document.getElementById('result').textContent = 'You have already reached your savings goal!'; | ||
return; | ||
} | ||
|
||
const amountNeeded = goalAmount - currentSavings; | ||
const monthlySavings = amountNeeded / timePeriod; | ||
|
||
document.getElementById('result').textContent = `You need to save ₹${monthlySavings.toFixed(2)} per month to reach your goal.`; | ||
} |
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,71 @@ | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
background: linear-gradient(to right, #f48a8a, #a3dbf5); | ||
margin: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} | ||
|
||
.calculator-container { | ||
background-color: #fff; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
padding: 20px; | ||
width: 500px; | ||
text-align: center; | ||
} | ||
|
||
h1 { | ||
color: #333; | ||
} | ||
|
||
.input-container { | ||
margin-bottom: 15px; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 5px; | ||
color: #555; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
padding: 8px; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
box-sizing: border-box; | ||
} | ||
|
||
button { | ||
background-color: #4caf50; | ||
color: #fff; | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
transform: scale(1.05); | ||
transition: 0.2s ease-in-out; | ||
} | ||
|
||
.result-container { | ||
margin-top: 20px; | ||
} | ||
|
||
#result { | ||
font-size: 18px; | ||
font-family: 'Courier New', Courier, monospace; | ||
font-weight: bold; | ||
color: #333; | ||
} | ||
|
||
.red { | ||
color: #f44336; | ||
} |
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