Skip to content

Commit

Permalink
Added Life Insurance Needs Calculator (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuvraj960 authored May 25, 2024
1 parent 72682b7 commit e4489de
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Calculators/Life-Insurance-Needs-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# <p align="center">Life Insurance Needs Calculator</p>

## Description :-

This is a web-based life insurance needs calculator that helps users determine how much life insurance they need based on their annual income, years of support needed, outstanding debts, funeral costs, savings, and investments.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Features :-

- Input fields for annual income, years of support needed, outstanding debts, funeral costs, savings, and investments.
- Calculation of the total life insurance needed based on the provided inputs.
- Clear and intuitive user interface.

## Screenshots :-

![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/d7bf0776-f235-4abd-bfd3-cd22f85a6ccc)
34 changes: 34 additions & 0 deletions Calculators/Life-Insurance-Needs-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!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>Life Insurance Needs Calculator</title>
</head>
<body>
<div class="container">
<h1>Life Insurance Needs Calculator</h1>
<form id="insuranceForm">
<label for="annualIncome">Annual Income ($):</label>
<input type="number" id="annualIncome" required>

<label for="yearsSupport">Years of Support Needed:</label>
<input type="number" id="yearsSupport" required>

<label for="outstandingDebts">Outstanding Debts ($):</label>
<input type="number" id="outstandingDebts" required>

<label for="funeralCosts">Funeral Costs ($):</label>
<input type="number" id="funeralCosts" required>

<label for="savings">Savings and Investments ($):</label>
<input type="number" id="savings" required>

<button type="button" onclick="calculateInsurance()">Calculate</button>
</form>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions Calculators/Life-Insurance-Needs-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function calculateInsurance() {
const annualIncome = parseFloat(document.getElementById('annualIncome').value);
const yearsSupport = parseFloat(document.getElementById('yearsSupport').value);
const outstandingDebts = parseFloat(document.getElementById('outstandingDebts').value);
const funeralCosts = parseFloat(document.getElementById('funeralCosts').value);
const savings = parseFloat(document.getElementById('savings').value);

if (isNaN(annualIncome) || isNaN(yearsSupport) || isNaN(outstandingDebts) || isNaN(funeralCosts) || isNaN(savings)) {
alert('Please enter valid numbers in all fields.');
return;
}

const incomeNeeds = annualIncome * yearsSupport;
const totalNeeds = incomeNeeds + outstandingDebts + funeralCosts;
const insuranceNeeds = totalNeeds - savings;

document.getElementById('result').textContent =
`You need approximately $${insuranceNeeds.toFixed(2)} in life insurance.`;
}
58 changes: 58 additions & 0 deletions Calculators/Life-Insurance-Needs-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
box-sizing: border-box;
}

h1 {
text-align: center;
margin-bottom: 20px;
}

label {
display: block;
margin-bottom: 5px;
}

input {
width: calc(100% - 20px);
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}

button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#result {
margin-top: 20px;
text-align: center;
font-size: 1.2em;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,20 @@ <h3>Calculates the length conversion between two specified units.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Life Insurance Needs Calculator</h2>
<h3>Calculates the amount we need in Life Insurance.</h3>
<div class="card-footer">
<a href="./Calculators/Life-Insurance-Needs-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Life-Insurance-Needs-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>Linear Equation Calculator</h2>
Expand Down

0 comments on commit e4489de

Please sign in to comment.