Present Value Calculator
The present value (PV) calculator helps you determine the current worth of a future sum of money or stream of cash flows, given a specified rate of return (discount rate). This is a fundamental concept in finance and investment, as it allows you to compare the value of money today versus money received in the future. The core idea is that money today is worth more than the same amount of money in the future due to its potential earning capacity (inflation, investment opportunities, risk).
Future Value (FV):
Discount Rate (r) (as a decimal):
Number of Periods (n):
Calculate Present Value
function calculatePresentValue() {
var futureValue = parseFloat(document.getElementById("futureValue").value);
var discountRate = parseFloat(document.getElementById("discountRate").value);
var numberOfPeriods = parseInt(document.getElementById("numberOfPeriods").value);
var resultElement = document.getElementById("result");
resultElement.innerHTML = ""; // Clear previous results
if (isNaN(futureValue) || isNaN(discountRate) || isNaN(numberOfPeriods)) {
resultElement.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (discountRate < 0 || numberOfPeriods < 0) {
resultElement.innerHTML = "Discount rate and number of periods cannot be negative.";
return;
}
// Formula: PV = FV / (1 + r)^n
var presentValue = futureValue / Math.pow((1 + discountRate), numberOfPeriods);
resultElement.innerHTML =
"
Present Value (PV): " + presentValue.toFixed(2) + "";
}
.calculator-container {
font-family: Arial, sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.input-section {
margin-bottom: 20px;
}
.input-section label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
.input-section input[type="number"] {
width: calc(100% – 22px);
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
.calculator-container button {
display: block;
width: 100%;
padding: 12px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
font-size: 1.1rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
text-align: center;
font-size: 1.2rem;
color: #333;
background-color: #eef;
padding: 15px;
border-radius: 5px;
}
#result p {
margin: 0;
}