Skip to content

Commit

Permalink
Added files for Life Insurance needs Calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuvraj960 committed May 23, 2024
1 parent ded4fe2 commit 42075d6
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Calculators/Life-Insurance-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Web Life Insurance Needs Calculator

![Calc-Image](image.png)

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.

## 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.
Binary file added Calculators/Life-Insurance-Calculator/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Calculators/Life-Insurance-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">
<title>Life Insurance Needs Calculator</title>
<link rel="stylesheet" href="styles.css">
</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-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-Calculator/styles.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;
}

0 comments on commit 42075d6

Please sign in to comment.