diff --git a/Calculators/Perpetuity-Calculator/README.md b/Calculators/Perpetuity-Calculator/README.md new file mode 100644 index 000000000..dde1a8e8f --- /dev/null +++ b/Calculators/Perpetuity-Calculator/README.md @@ -0,0 +1,36 @@ +#

Perpetuity Calculator

+ +## Description :- + +A simple and interactive tool to calculate the **present value (PV)** of a perpetuity, an infinite series of cash flows, using the formula: + +**PV = C / r** + +Where: +- **PV** is the present value +- **C** is the annual cash flow +- **r** is the discount rate + +This tool makes financial calculations easier and helps users understand perpetuities better. + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Features :- + +- **Perpetuity Calculation**: Input fields to calculate present value based on cash flow and discount rate. +- **Reset Functionality**: Clear all fields and results with a single click. +- **Error Handling**: Alerts users with meaningful error messages for invalid inputs. +- **Tooltips**: User guidance on input requirements. +- **Responsive Design**: Adapts to all devices for seamless usability. + +## Formula :- + +**Present Value = Cash Flow / Discount Rate** + +## Screenshots :- + +![image](https://github.com/user-attachments/assets/a68ff8ad-781a-4943-a125-4e1b2a57cf5a) diff --git a/Calculators/Perpetuity-Calculator/index.html b/Calculators/Perpetuity-Calculator/index.html new file mode 100644 index 000000000..d70257326 --- /dev/null +++ b/Calculators/Perpetuity-Calculator/index.html @@ -0,0 +1,38 @@ + + + + + + + + Perpetuity Calculator + + + +
+

Perpetuity Calculator

+

Calculate the present value of an infinite series of cash flows.

+ +
+ + + Example: 1000 + + + + Example: 5 (for 5%) +
+ + + + +
+

Result:

+

Present Value (PV): --

+
+
+ + + + + \ No newline at end of file diff --git a/Calculators/Perpetuity-Calculator/script.js b/Calculators/Perpetuity-Calculator/script.js new file mode 100644 index 000000000..912e27860 --- /dev/null +++ b/Calculators/Perpetuity-Calculator/script.js @@ -0,0 +1,25 @@ +document.getElementById("calculateBtn").addEventListener("click", () => { + const cashFlow = parseFloat(document.getElementById("cashFlow").value); + const discountRate = parseFloat(document.getElementById("discountRate").value); + + if (isNaN(cashFlow) || cashFlow <= 0) { + alert("Please enter a valid annual cash flow (greater than 0)."); + return; + } + + if (isNaN(discountRate) || discountRate <= 0 || discountRate >= 100) { + alert("Please enter a valid discount rate (greater than 0 and less than 100)."); + return; + } + + const rateDecimal = discountRate / 100; + const presentValue = cashFlow / rateDecimal; + + document.getElementById("presentValue").textContent = `Present Value (PV): ${presentValue.toFixed(2)}`; +}); + +document.getElementById("resetBtn").addEventListener("click", () => { + document.getElementById("cashFlow").value = ""; + document.getElementById("discountRate").value = ""; + document.getElementById("presentValue").textContent = "Present Value (PV): --"; +}); \ No newline at end of file diff --git a/Calculators/Perpetuity-Calculator/style.css b/Calculators/Perpetuity-Calculator/style.css new file mode 100644 index 000000000..eadd44d24 --- /dev/null +++ b/Calculators/Perpetuity-Calculator/style.css @@ -0,0 +1,85 @@ +body { + font-family: Arial, sans-serif; + background: linear-gradient(135deg, #2b5876, #4e4376); + color: white; + text-align: center; + margin: 0; + padding: 0; + height: 100vh; + display: flex; + justify-content: center; + align-items: center; +} + +.calculator { + background-color: rgba(0, 0, 0, 0.8); + border-radius: 15px; + padding: 20px 30px; + box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2); +} + +h1 { + margin-bottom: 10px; + font-size: 26px; + color: #84cef5; +} + +p { + margin-bottom: 15px; + font-size: 16px; +} + +.input-section label { + display: block; + margin: 10px 0 5px; + font-size: 14px; + color: #ccc; +} + +input { + padding: 10px; + width: calc(100% - 20px); + margin-bottom: 10px; + border: none; + border-radius: 5px; + font-size: 16px; +} + +.tooltip { + font-size: 12px; + color: #aaa; + display: block; + margin-bottom: 10px; +} + +button { + padding: 10px 20px; + background-color: #84cef5; + border: none; + border-radius: 5px; + font-size: 16px; + color: white; + cursor: pointer; + margin: 5px; + transition: transform 0.3s ease; +} + +button:hover { + transform: scale(1.1); + background-color: #67b3e1; +} + +#output { + margin-top: 20px; +} + +#presentValue { + font-size: 18px; + font-weight: bold; +} + +@media (max-width: 768px) { + body { + padding: 20px; + } +} \ No newline at end of file diff --git a/calculators.json b/calculators.json index c6e65cedf..480d60273 100644 --- a/calculators.json +++ b/calculators.json @@ -1811,6 +1811,12 @@ "link": "./Calculators/Permutation-Combination-Calculator/index.html", "source": "https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Permutation-Combination-Calculator" }, + { + "title": "Perpetuity Calculator", + "description": "Calculates the present value of a perpetuity.", + "link": "./Calculators/Perpetuity-Calculator/index.html", + "source": "https://github.com/username/CalcDiverse/tree/main/Calculators/Perpetuity-Calculator" + }, { "title": "Pet Age Calculator", "description": "Calculates a pet's age in human years.",