emi calculator
<!DOCTYPE html>
<html>
<head>
<title>EMI Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
}
</style>
</head>
<body>
<h2>EMI Calculator</h2>
<form>
<label for="loanAmount">Loan Amount:</label>
<input type="number" id="loanAmount" required><br><br>
<label for="interestRate">Interest Rate (% per annum):</label>
<input type="number" id="interestRate" required><br><br>
<label for="loanTenure">Loan Tenure (in months):</label>
<input type="number" id="loanTenure" required><br><br>
<button type="button" onclick="calculateEMI()">Calculate EMI</button>
</form>
<br>
<div id="result"></div>
<script>
function calculateEMI() {
var loanAmount = parseFloat(document.getElementById('loanAmount').value);
var interestRate = parseFloat(document.getElementById('interestRate').value);
var loanTenure = parseFloat(document.getElementById('loanTenure').value);
if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTenure)) {
document.getElementById('result').innerHTML = 'Please enter valid numbers.';
return;
}
var monthlyInterestRate = interestRate / 1200;
var emi = (loanAmount * monthlyInterestRate * Math.pow(1 + monthlyInterestRate, loanTenure)) / (Math.pow(1 + monthlyInterestRate, loanTenure) - 1);
document.getElementById('result').innerHTML = 'EMI: ' + emi.toFixed(2);
}
</script>
</body>
</html>
Comments
Post a Comment