Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Inflation Calculator #1142

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Calculators/Inflation-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!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="../Inflation-Calculator/styles.css">
<title>Inflation Calculator</title>
</head>

<body>
<div class="container-box">
<h2>Inflation Calculator</h2>
<form>
<div class="input-box">
<input type="number" name="" required id="current-cost-input">
<label>Current Cost</label>
</div>
<div class="input-box">
<input type="number" name="" required id="pa-input">
<label>Rate of inflation(p.a)</label>
</div>
<div class="input-box">
<input type="number" name="" required id="noy-input">
<label>Time Period</label>
</div>
<div class="error-container">

</div>

<div class="option-container"></div>

<a href="#" class="btn">
<span></span>
<span></span>
<span></span>
<span></span>
Submit
</a>
</form>

<div id="content-box">

</div>
</div>

<script src="./script.js"></script>
</body>

</html>
22 changes: 22 additions & 0 deletions Calculators/Inflation-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// eventlistener for submit button
const button = document.querySelector('.btn')
button.addEventListener('click', function () {
// take user age input and check error
const currentCost = document.getElementById('current-cost-input').value
const rateOfInflation = document.getElementById('pa-input').value
const noOfYears = document.getElementById('noy-input').value
// Formula for calculation
const futureCost = currentCost * (Math.pow((1 + (rateOfInflation / 100)), noOfYears));
// display area
const contentBox = document.querySelector('.content-box')
var existingDiv = document.querySelector('.content')
if (!existingDiv) {
var displayDiv = document.createElement('div')
displayDiv.className = 'content'
contentBox.appendChild(displayDiv)
displayDiv.textContent = "Future Cost : " + String.fromCharCode(8377) + Math.floor(futureCost);
}
else {
existingDiv.textContent = `Wrong Calculation`
}
})
157 changes: 157 additions & 0 deletions Calculators/Inflation-Calculator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
html {
height: 100%;
}

body {
margin: 0;
padding: 0;
font-family: sans-serif;
background: linear-gradient(#141e30, #492455);
}

.container-box {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
padding: 40px;
transform: translate(-50%, -50%);
background: rgba(0, 0, 0, .5);
box-sizing: border-box;
box-shadow: 0 15px 25px rgba(0, 0, 0, .6);
border-radius: 10px;
}

.container-box h2 {
margin: 0 0 30px;
padding: 0;
color: #fff;
text-align: center;
}

.container-box .input-box {
position: relative;
}

.container-box .input-box input {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #fff;
margin-bottom: 12px;
border: none;
border-bottom: 1px solid #fff;
outline: none;
background: transparent;
}

.container-box .input-box label {
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 16px;
color: #fff;
pointer-events: none;
transition: .5s;
}

.container-box .input-box input:focus~label,
.container-box .input-box input:valid~label {
top: -20px;
left: 0;
color: #8003f4;
font-size: 13px;
}

.container-box form a {
position: relative;
display: inline-block;
padding: 10px 20px;
color: #03e9f4;
font-size: 16px;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
transition: .5s;
margin-top: 40px;
letter-spacing: 4px;
border: 2px solid #03e9f4;
}

.container-box a:hover {
background: #1bbe72;
color: #fff;
border-radius: 5px;
box-shadow: 0 0 5px #2c7b1c;
}

.container-box a span {
position: absolute;
display: block;
}


.content {
color: #fff;
padding: 4px;
text-align: center;
}

.content-box {
margin-top: 20px;
border: 2px solid #03e9f4;
border-radius: 4px;
}

.error-box,
.option-error-box {
background-color: #ffcccc;
color: #ff0000;
border: 1px solid #ff0000;
padding: 10px;
border-radius: 10px;
margin-bottom: 10px;
}

.input-group {
position: relative;
margin-bottom: 33px;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.select-box {
position: relative;
margin-top: 10px;
}

.select-box option {
background: rgba(0, 0, 0, .5);
color: #fff;
overflow: auto;
}

.select-box label {
position: absolute;
top: 0;
left: 0;
padding: 5px 0;
margin-bottom: 5px;
font-size: 16px;
color: #fff;
pointer-events: none;
transition: .5s;
}

.select-box select {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #fff;
margin-top: 25px;
margin-bottom: 30px;
border: none;
border-bottom: 1px solid #fff;
outline: none;
background: transparent;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,20 @@ <h3>Converts between infix, prefix and postfix expressions.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Inflation Calculator</h2>
<h3>Which takes Current Cost, Rate of Inflation, Time Period and Future Cost</h3>
<div class="card-footer">
<a href="./Calculators/Inflation-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/thenagarajanv/CalcDiverse/tree/main/Calculators/Inflation-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Intelligence Calculator</h2>
Expand Down