Enter the details of your car to estimate its current value after depreciation.
The price you originally paid for the car.
The calendar year you bought the car.
The current calendar year for valuation.
The average miles driven per year.
Excellent
Good
Fair
Poor
Select the current condition of your car.
Your Car's Estimated Value
$0.00
Car Age: 0 years
Total Mileage: 0 miles
Estimated Value Loss: $0.00
Formula Used: The estimated value is calculated using a combination of the car's age, total mileage, and condition. A base depreciation rate is applied, adjusted by factors for mileage and condition.
Estimated Value = Original Price * (1 – (Age Factor + Mileage Factor + Condition Factor))
*Note: This is a simplified model. Real-world depreciation can vary significantly.*
Car Depreciation Value Over Time
This chart visualizes how your car's estimated value decreases year by year, based on the inputs provided.
Depreciation Schedule
Year
Age (Years)
Estimated Value
Value Lost This Year
Understanding Car Price Depreciation
What is Car Price Depreciation?
Car price depreciation refers to the decrease in a vehicle's value over time. Almost all cars lose value from the moment they are driven off the lot. This loss is a fundamental aspect of car ownership and impacts its resale or trade-in value. Understanding car price depreciation is crucial for budgeting, selling, and making informed purchasing decisions.
Who should use a car price depreciation calculator?
Car Buyers: To estimate the future value of a new car they are considering and understand the total cost of ownership.
Car Sellers: To set a realistic asking price for their used vehicle.
Car Owners: To track the value of their asset and plan for future car purchases or financial needs.
Financial Planners: To assess the value of a depreciating asset in a client's portfolio.
Common Misconceptions about Car Price Depreciation:
Myth: Cars stop depreciating after a certain number of years. Reality: While the rate slows down, cars continue to depreciate throughout their lifespan, especially as maintenance costs rise and they become outdated.
Myth: Only the age of the car matters. Reality: Mileage, condition, maintenance history, market demand, and even color can significantly influence depreciation.
Myth: A well-maintained car doesn't depreciate much. Reality: While good maintenance preserves value, it doesn't stop the inevitable decline due to age and obsolescence.
Car Price Depreciation Formula and Mathematical Explanation
Calculating precise car depreciation is complex, as it involves numerous market factors. However, a common approach uses a formula that considers the car's age, mileage, and condition. Here's a simplified explanation of a typical car price depreciation calculation:
Core Formula Concept:
The estimated value is generally calculated by starting with the original price and subtracting accumulated depreciation. Depreciation is often modeled as a percentage loss per year, with adjustments for mileage and condition.
Simplified Depreciation Formula:
Estimated Value = Original Price * (1 - Total Depreciation Percentage)
Where Total Depreciation Percentage is a sum of factors:
Original Price: The initial purchase price of the vehicle.
Year of Purchase: The year the car was bought new or used.
Current Year: The year for which the valuation is being calculated.
Annual Mileage: The average number of miles driven per year.
Car Condition: A qualitative assessment (e.g., Excellent, Good, Fair, Poor) translated into a numerical factor.
Detailed Factor Calculation (Conceptual):
Age Factor: Represents the depreciation due to the car getting older. A common model assumes a higher percentage loss in the first few years, tapering off. For example, a car might lose 15-25% in the first year, 10-15% in the second, and 5-10% in subsequent years. The calculator sums these annual losses.
Mileage Factor: Accounts for wear and tear from usage. Cars driven more miles generally depreciate faster. A certain mileage threshold might add an extra percentage point of depreciation.
Condition Factor: Reflects the physical state of the car. Excellent condition cars depreciate less than those in fair or poor condition, which may have visible damage, mechanical issues, or require significant repairs.
Variables Table:
Depreciation Variables
Variable
Meaning
Unit
Typical Range/Values
Original Price
Initial cost of the car
Currency (e.g., $)
$10,000 – $100,000+
Year of Purchase
The year the vehicle was acquired
Year (Integer)
e.g., 2015-2024
Current Year
The year of valuation
Year (Integer)
e.g., 2024
Annual Mileage
Average miles driven yearly
Miles (Integer)
5,000 – 20,000+
Car Condition
Overall state of the vehicle
Categorical (Excellent, Good, Fair, Poor)
Mapped to depreciation multipliers
Age Factor
Depreciation component due to age
Percentage (%)
Varies (e.g., 5% – 20% per year of age)
Mileage Factor
Depreciation component due to usage
Percentage (%)
Varies (e.g., 0% – 10% based on mileage)
Condition Factor
Depreciation component due to state
Percentage (%)
Varies (e.g., 0% – 15% based on condition)
Practical Examples
Example 1: Average Usage Sedan
Sarah bought a new sedan in 2020 for $28,000. She drives about 12,000 miles per year and keeps her car in good condition with regular maintenance. We are calculating its value in 2024.
Inputs: Original Price = $28,000, Year of Purchase = 2020, Current Year = 2024, Annual Mileage = 12,000, Condition = Good.
Calculation:
Car Age = 2024 – 2020 = 4 years.
Total Mileage = 4 years * 12,000 miles/year = 48,000 miles.
Estimated Age Factor: Let's assume an average annual depreciation of 8% for the first 4 years, compounded: Approx. 28.4% loss over 4 years.
Estimated Mileage Factor: For 48,000 miles, let's add 4%.
Estimated Condition Factor: Good condition adds 3%.
Result: The estimated value of Sarah's car in 2024 is approximately $18,088. The total value loss is $9,912.
Interpretation: This shows a significant drop in value, typical for cars a few years old with average mileage. Sarah should expect to get around this amount if she were to sell it.
Example 2: High-Mileage SUV
Mark purchased an SUV in 2019 for $45,000. He uses it extensively for work, averaging 20,000 miles per year. The SUV is in fair condition due to minor cosmetic wear. We want to estimate its value in 2024.
Inputs: Original Price = $45,000, Year of Purchase = 2019, Current Year = 2024, Annual Mileage = 20,000, Condition = Fair.
Calculation:
Car Age = 2024 – 2019 = 5 years.
Total Mileage = 5 years * 20,000 miles/year = 100,000 miles.
Estimated Age Factor: With 5 years, let's assume an average of 9% annual depreciation: Approx. 38.6% loss.
Estimated Mileage Factor: High mileage (100,000+) adds a significant 10%.
Result: Mark's SUV is estimated to be worth around $19,530 in 2024. The total value loss is $25,470.
Interpretation: The combination of age and very high mileage has led to a substantial depreciation, significantly more than the average sedan. The fair condition further reduces its value.
How to Use This Car Price Depreciation Calculator
Our car price depreciation calculator is designed for simplicity and ease of use. Follow these steps to get an estimate of your car's current value:
Enter Original Purchase Price: Input the exact amount you paid for the car when you first acquired it.
Select Year of Purchase: Choose the calendar year you bought the car.
Specify Current Year: Enter the current calendar year. This is usually pre-filled but can be adjusted if you're calculating for a future date.
Input Average Annual Mileage: Provide the average number of miles you drive each year. If you don't know the exact average, use a reasonable estimate.
Select Car Condition: Choose from the dropdown menu the option that best describes your car's current condition: Excellent, Good, Fair, or Poor.
Click 'Calculate Depreciation': Once all fields are filled, press the button.
How to Read Results:
Main Result (Estimated Value): This is the primary output, showing the approximate current market value of your car after accounting for depreciation factors.
Car Age: The number of years since you purchased the car.
Total Mileage: The total estimated miles driven based on purchase year and annual mileage.
Estimated Value Loss: The total amount of value your car has lost since purchase.
Depreciation Schedule Table: Shows a year-by-year breakdown of how the car's value is estimated to decrease.
Chart: Provides a visual representation of the depreciation trend over time.
Decision-Making Guidance: Use these results to inform decisions such as:
Setting a competitive price if you plan to sell your car.
Negotiating a trade-in value.
Understanding the true cost of owning your vehicle.
Planning your budget for a future car purchase.
Remember, this calculator provides an estimate. For a precise valuation, consider consulting professional appraisals or checking listings for similar vehicles in your local market.
Key Factors That Affect Car Price Depreciation Results
While our calculator uses core inputs, numerous other factors can significantly influence how much a car actually depreciates:
Make and Model: Some brands and specific models hold their value better than others due to reputation for reliability, desirability, or lower maintenance costs. Luxury cars often depreciate faster in percentage terms initially.
Trim Level and Features: Higher trim levels and desirable features (e.g., sunroof, advanced safety tech, premium audio) can command a higher resale value compared to base models, though their initial cost is also higher.
Vehicle History Report (VHR): Accidents, title issues (salvage, flood damage), and multiple previous owners reported on a VHR (like CarFax or AutoCheck) drastically reduce a car's value. A clean history is paramount.
Maintenance Records: Consistent, documented maintenance suggests the car has been well cared for, which can mitigate depreciation compared to a car with a spotty or non-existent service history.
Fuel Efficiency and Type: In times of high fuel prices, fuel-efficient vehicles (hybrids, smaller engines) may depreciate slower or even hold value better than their less efficient counterparts. Conversely, demand for certain vehicle types (e.g., trucks, SUVs) can outweigh fuel concerns.
Location and Market Demand: Regional preferences play a role. For instance, SUVs and 4WD vehicles may hold value better in snowy regions, while convertibles might be more popular in warmer climates. Overall economic conditions also affect demand.
Color: While seemingly minor, neutral colors like white, black, gray, and silver typically have broader appeal and may depreciate slower than more polarizing colors like bright yellow or lime green.
Aftermarket Modifications: While some modifications might increase a car's appeal to a niche market, many can actually decrease its value and appeal to the broader used car market, making depreciation worse.
Frequently Asked Questions (FAQ)
What is the biggest factor in car depreciation?The biggest factors are typically age and mileage. Cars lose a significant portion of their value in the first few years and the first 50,000-60,000 miles.
Does depreciation stop after 10 years?No, depreciation doesn't entirely stop. The rate slows dramatically, but a 15-year-old car will still be worth less than the same model that's 10 years old, assuming similar condition and mileage. It becomes less about percentage loss and more about the car's condition and potential for classic car status.
Which car types depreciate the fastest?Luxury brands, exotic sports cars, electric vehicles (historically, though this is changing), and minivans often depreciate faster than average. Mainstream sedans and reliable SUVs tend to hold their value better.
How does buying a used car affect depreciation?When you buy a used car, you avoid the steepest part of the depreciation curve (the first 1-3 years). The car you buy has already lost a significant chunk of its value, so its future depreciation, while still present, will be less dramatic in dollar amounts compared to buying new.
Can financing a car affect its depreciation?The financing method itself (loan vs. lease, interest rate) doesn't directly change the car's market value (depreciation). However, negative equity (owing more on the loan than the car is worth) can make depreciation feel more impactful when selling or trading, as you'll need to cover the difference.
Is there a way to slow down car depreciation?Yes. Minimize mileage where possible, keep the car in excellent mechanical and cosmetic condition, perform regular maintenance and keep records, avoid accidents, and choose a model known for good resale value. Parking indoors can also help preserve paint and interior.
How accurate are online depreciation calculators?Online calculators provide a good estimate based on general models. They are excellent for understanding trends and relative value changes. However, they cannot account for every unique factor (specific accident history, rare options, hyper-local market fluctuations) that affects a car's final sale price.
What's the difference between depreciation and market value?Depreciation is the calculated loss in value over time. Market value is the price a car could realistically sell for *today* in the current market, considering its condition, mileage, features, and demand. Depreciation is a major component of market value, but market value also includes supply/demand dynamics.
Calculate your car's fuel economy and estimate your annual fuel costs.
var originalPriceInput = document.getElementById('originalPrice');
var purchaseYearInput = document.getElementById('purchaseYear');
var currentYearInput = document.getElementById('currentYear');
var annualMileageInput = document.getElementById('annualMileage');
var conditionSelect = document.getElementById('condition');
var originalPriceError = document.getElementById('originalPriceError');
var purchaseYearError = document.getElementById('purchaseYearError');
var currentYearError = document.getElementById('currentYearError');
var annualMileageError = document.getElementById('annualMileageError');
var resultsDiv = document.getElementById('results');
var mainResultDiv = document.getElementById('mainResult');
var currentAgeDiv = document.getElementById('currentAge');
var totalMileageDiv = document.getElementById('totalMileage');
var estimatedValueLossDiv = document.getElementById('estimatedValueLoss');
var depreciationTableBody = document.querySelector('#depreciationTable tbody');
var chartCanvas = document.getElementById('depreciationChart');
var chartInstance = null;
var defaultOriginalPrice = 25000;
var defaultPurchaseYear = 2020;
var defaultCurrentYear = 2024;
var defaultAnnualMileage = 12000;
function validateInput(input, errorElement, min, max) {
var value = parseFloat(input.value);
var isValid = true;
errorElement.textContent = ";
if (isNaN(value)) {
errorElement.textContent = 'Please enter a valid number.';
isValid = false;
} else if (value max) {
errorElement.textContent = 'Value is unreasonably high.';
isValid = false;
}
return isValid;
}
function getConditionFactor(condition) {
switch (condition) {
case 'excellent': return 0.02; // 2% extra depreciation penalty
case 'good': return 0.04; // 4% extra depreciation penalty
case 'fair': return 0.08; // 8% extra depreciation penalty
case 'poor': return 0.15; // 15% extra depreciation penalty
default: return 0.04; // Default to good
}
}
function calculateDepreciation() {
var originalPrice = parseFloat(originalPriceInput.value);
var purchaseYear = parseInt(purchaseYearInput.value);
var currentYear = parseInt(currentYearInput.value);
var annualMileage = parseFloat(annualMileageInput.value);
var condition = conditionSelect.value;
var validOriginalPrice = validateInput(originalPriceInput, originalPriceError, 0);
var validPurchaseYear = validateInput(purchaseYearInput, purchaseYearError, 1900, currentYearInput.value || new Date().getFullYear());
var validCurrentYear = validateInput(currentYearInput, currentYearError, purchaseYearInput.value || 1900, new Date().getFullYear() + 5);
var validAnnualMileage = validateInput(annualMileageInput, annualMileageError, 0);
if (!validOriginalPrice || !validPurchaseYear || !validCurrentYear || !validAnnualMileage) {
resultsDiv.style.display = 'none';
return;
}
if (currentYear < purchaseYear) {
currentYearError.textContent = 'Current year cannot be before purchase year.';
resultsDiv.style.display = 'none';
return;
}
var carAge = currentYear – purchaseYear;
var totalMileage = carAge * annualMileage;
var conditionFactor = getConditionFactor(condition);
// Simplified Depreciation Model Parameters
var baseDepreciationRatePerYear = 0.08; // 8% base annual depreciation
var mileageDepreciationRatePerMile = 0.00001; // $0.00001 per mile
var maxMileageForRate = 100000; // Mileage beyond which rate might change or cap
// Calculate Age Factor
var ageFactor = 0;
var currentEstValue = originalPrice;
var depreciationScheduleData = [];
for (var i = 0; i < carAge; i++) {
var yearAge = i + 1;
var ageRelatedDepreciation = baseDepreciationRatePerYear * currentEstValue;
// Adjust for potentially higher depreciation in early years if needed (simplified here)
// For this model, we apply a flat rate for simplicity but acknowledge it's not fully accurate.
// A more complex model would use exponential decay or tiered rates.
currentEstValue -= ageRelatedDepreciation;
if (currentEstValue 0) {
// Simple linear model: higher mileage = higher factor
mileageFactor = (totalMileage / maxMileageForRate) * 0.05; // 5% depreciation for every 100k miles over base
if (mileageFactor > 0.15) mileageFactor = 0.15; // Cap mileage factor at 15% for this model
}
// Calculate Condition Factor
var conditionFactorValue = conditionFactor; // Directly use the value from getConditionFactor
// Total Depreciation Percentage
var totalDepreciationPercentage = ageFactor + mileageFactor + conditionFactorValue;
if (totalDepreciationPercentage > 0.95) totalDepreciationPercentage = 0.95; // Cap total depreciation at 95%
// Calculate Final Estimated Value
var estimatedValue = originalPrice * (1 – totalDepreciationPercentage);
if (estimatedValue < 0) estimatedValue = 0;
var valueLoss = originalPrice – estimatedValue;
// Update Results Display
mainResultDiv.textContent = '$' + estimatedValue.toFixed(2);
currentAgeDiv.textContent = 'Car Age: ' + carAge + ' years';
totalMileageDiv.textContent = 'Total Mileage: ' + totalMileage.toLocaleString() + ' miles';
estimatedValueLossDiv.textContent = 'Estimated Value Loss: $' + valueLoss.toFixed(2);
resultsDiv.style.display = 'block';
// Populate Depreciation Table
depreciationTableBody.innerHTML = ''; // Clear previous rows
currentEstValue = originalPrice; // Reset for schedule calculation
for (var i = 0; i < carAge + 5; i++) { // Show current age + 5 future years
var year = purchaseYear + i;
var age = i;
var yearValue = originalPrice;
var valueLostThisYear = 0;
if (i === 0) {
yearValue = originalPrice; // Start value at purchase
} else {
// Recalculate value for each year in the schedule based on a simplified annual decay
var currentYearAgeFactor = 0;
var currentYearMileageFactor = 0;
var currentYearConditionFactor = getConditionFactor(condition); // Condition assumed constant for future projection
// Age Factor for the schedule (simplified annual decay)
var yearAgeDepreciation = baseDepreciationRatePerYear * currentEstValue;
currentEstValue -= yearAgeDepreciation;
if (currentEstValue 0) {
currentYearMileageFactor = (projectedTotalMileage / maxMileageForRate) * 0.05;
if (currentYearMileageFactor > 0.15) currentYearMileageFactor = 0.15;
}
var totalSchedDepreciation = (baseDepreciationRatePerYear) + currentYearMileageFactor + currentYearConditionFactor;
if (totalSchedDepreciation > 0.95) totalSchedDepreciation = 0.95;
yearValue = originalPrice * (1 – totalSchedDepreciation);
if (yearValue 0) ? (originalPrice * (1 – ((age-1)*annualMileage*0.00001 + (age-1)*baseDepreciationRatePerYear + conditionFactorValue))) – yearValue : 0;
if(valueLostThisYear < 0) valueLostThisYear = 0; // Ensure positive loss
if (i === 1) { // Special case for the first year's loss calculation
valueLostThisYear = originalPrice – (originalPrice * (1 – (baseDepreciationRatePerYear + (annualMileage*0.00001) + conditionFactorValue)));
if(valueLostThisYear 0) {
var avgYearlyDepRate = baseDepreciationRatePerYear + (annualMileage * mileageDepreciationRatePerMile * (i / maxMileageForRate)) + scheduleConditionFactor;
if(avgYearlyDepRate > 0.2) avgYearlyDepRate = 0.2; // Cap yearly rate for projection
scheduledValueCalc = originalPrice * Math.pow((1 – avgYearlyDepRate), i);
if (scheduledValueCalc 1) {
var prevYearValue = originalPrice * Math.pow((1 – avgYearlyDepRate), (i-1));
valueLostThisYear = prevYearValue – scheduledValueCalc;
} else if (i === 1) {
valueLostThisYear = originalPrice – scheduledValueCalc;
} else {
valueLostThisYear = 0;
}
if(valueLostThisYear < 0) valueLostThisYear = 0;
} else { // Year 0 (purchase year)
scheduledValueCalc = originalPrice;
valueLostThisYear = 0;
}
if (scheduledValueCalc < 0) scheduledValueCalc = 0;
var row = depreciationTableBody.insertRow();
row.innerHTML = '
' + year + '
' +
'
' + age + '
' +
'
$' + scheduledValueCalc.toFixed(2) + '
' +
'
$' + valueLostThisYear.toFixed(2) + '
';
}
updateChart();
}
function updateChart() {
if (chartInstance) {
chartInstance.destroy();
}
var originalPrice = parseFloat(originalPriceInput.value);
var purchaseYear = parseInt(purchaseYearInput.value);
var currentYear = parseInt(currentYearInput.value);
var annualMileage = parseFloat(annualMileageInput.value);
var condition = conditionSelect.value;
// Re-validate inputs for chart update safety
var validOriginalPrice = validateInput(originalPriceInput, originalPriceError, 0);
var validPurchaseYear = validateInput(purchaseYearInput, purchaseYearError, 1900, currentYearInput.value || new Date().getFullYear());
var validCurrentYear = validateInput(currentYearInput, currentYearError, purchaseYearInput.value || 1900, new Date().getFullYear() + 5);
var validAnnualMileage = validateInput(annualMileageInput, annualMileageError, 0);
if (!validOriginalPrice || !validPurchaseYear || !validCurrentYear || !validAnnualMileage || currentYear < purchaseYear) {
return; // Don't update chart if inputs are invalid
}
var labels = [];
var estimatedValues = [];
var valueLosses = []; // Data series for value lost each year
var carAge = currentYear – purchaseYear;
var currentEstimatedValue = originalPrice;
var currentTotalMileage = 0;
// Calculate values for the chart (approx. 10-15 points for smooth curve)
var maxYearsToShow = carAge + 10; // Show current age + 10 future years
var step = Math.max(1, Math.floor(maxYearsToShow / 15)); // Ensure at least 1 year step
for (var i = 0; i <= maxYearsToShow; i++) {
var year = purchaseYear + i;
var age = i;
currentTotalMileage = age * annualMileage;
// Simplified Depreciation Model Parameters for Chart
var baseDepreciationRatePerYear = 0.08; // 8% base annual depreciation
var mileageDepreciationRatePerMile = 0.00001; // $0.00001 per mile
var maxMileageForRate = 100000;
// Calculate Age Factor
var ageFactorChart = 0;
var valueAfterAge = originalPrice;
for (var j = 0; j 0) {
mileageFactorChart = (currentTotalMileage / maxMileageForRate) * 0.05;
if (mileageFactorChart > 0.15) mileageFactorChart = 0.15;
}
// Calculate Condition Factor
var conditionFactorChart = getConditionFactor(condition);
var totalDepreciationPercentageChart = ageFactorChart + mileageFactorChart + conditionFactorChart;
if (totalDepreciationPercentageChart > 0.95) totalDepreciationPercentageChart = 0.95;
var estimatedValueChart = originalPrice * (1 – totalDepreciationPercentageChart);
if (estimatedValueChart 0) {
// Get the value from the previous year to calculate the difference
var prevYearValue = 0;
if (i > 1) {
var prevAge = i – 1;
var prevTotalMileage = prevAge * annualMileage;
var prevAgeFactor = 0;
var valueAfterPrevAge = originalPrice;
for (var k = 0; k 0) {
prevMileageFactor = (prevTotalMileage / maxMileageForRate) * 0.05;
if (prevMileageFactor > 0.15) prevMileageFactor = 0.15;
}
var prevTotalDepreciation = prevAgeFactor + prevMileageFactor + conditionFactorChart;
if (prevTotalDepreciation > 0.95) prevTotalDepreciation = 0.95;
prevYearValue = originalPrice * (1 – prevTotalDepreciation);
if (prevYearValue < 0) prevYearValue = 0;
} else { // First year (i=1)
prevYearValue = originalPrice;
}
valueLostThisYear = prevYearValue – estimatedValueChart;
if (valueLostThisYear < 0) valueLostThisYear = 0; // Ensure positive loss
}
valueLosses.push(valueLostThisYear);
}
var ctx = chartCanvas.getContext('2d');
chartInstance = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Estimated Value ($)',
data: estimatedValues,
borderColor: '#004a99',
backgroundColor: 'rgba(0, 74, 153, 0.1)',
fill: false,
tension: 0.4,
pointRadius: 2
},
{
label: 'Value Lost This Year ($)',
data: valueLosses,
borderColor: '#dc3545',
backgroundColor: 'rgba(220, 53, 69, 0.1)',
fill: false,
tension: 0.4,
pointRadius: 2
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return '$' + value.toLocaleString();
}
}
}
},
plugins: {
tooltip: {
callbacks: {
label: function(context) {
var label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += '$' + context.parsed.y.toLocaleString();
}
return label;
}
}
}
}
}
});
}
function resetCalculator() {
originalPriceInput.value = defaultOriginalPrice;
purchaseYearInput.value = defaultPurchaseYear;
currentYearInput.value = defaultCurrentYear;
annualMileageInput.value = defaultAnnualMileage;
conditionSelect.value = 'good';
originalPriceError.textContent = '';
purchaseYearError.textContent = '';
currentYearError.textContent = '';
annualMileageError.textContent = '';
resultsDiv.style.display = 'none';
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
depreciationTableBody.innerHTML = ''; // Clear table
}
function copyResults() {
var resultText = "— Car Depreciation Estimate —\n\n";
resultText += "Estimated Value: " + mainResultDiv.textContent + "\n";
resultText += document.getElementById('currentAge').textContent + "\n";
resultText += document.getElementById('totalMileage').textContent + "\n";
resultText += document.getElementById('estimatedValueLoss').textContent + "\n\n";
resultText += "Key Assumptions:\n";
resultText += "- Original Price: $" + parseFloat(originalPriceInput.value).toLocaleString() + "\n";
resultText += "- Purchase Year: " + purchaseYearInput.value + "\n";
resultText += "- Current Year: " + currentYearInput.value + "\n";
resultText += "- Annual Mileage: " + parseFloat(annualMileageInput.value).toLocaleString() + " miles\n";
resultText += "- Condition: " + conditionSelect.options[conditionSelect.selectedIndex].text + "\n\n";
resultText += "Depreciation Schedule:\n";
var rows = depreciationTableBody.querySelectorAll('tr');
rows.forEach(function(row) {
var cells = row.querySelectorAll('td');
resultText += cells[0].textContent + " (Age " + cells[1].textContent.split(' ')[0] + "): " + cells[2].textContent + " (Loss: " + cells[3].textContent + ")\n";
});
var textArea = document.createElement("textarea");
textArea.value = resultText;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
textArea.remove();
// Provide visual feedback
var originalButtonText = button.innerText;
button.innerText = "Copied!";
setTimeout(function() {
button.innerText = originalButtonText;
}, 2000);
}
// Initial Calculation on Load
document.addEventListener('DOMContentLoaded', function() {
// Set sensible defaults if inputs are empty
if (!originalPriceInput.value) originalPriceInput.value = defaultOriginalPrice;
if (!purchaseYearInput.value) purchaseYearInput.value = defaultPurchaseYear;
if (!currentYearInput.value) currentYearInput.value = defaultCurrentYear;
if (!annualMileageInput.value) annualMileageInput.value = defaultAnnualMileage;
calculateDepreciation(); // Perform initial calculation
});