Posts

Showing posts from September, 2025
import { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; export default function LoanCalculator() { const [amount, setAmount] = useState(100000); const [rate, setRate] = useState(10); const [years, setYears] = useState(5); const [result, setResult] = useState(null); const calculateLoan = () => { const principal = parseFloat(amount); const monthlyRate = parseFloat(rate) / 100 / 12; const months = parseInt(years) * 12; if (principal > 0 && monthlyRate > 0 && months > 0) { const emi = (principal * monthlyRate * Math.pow(1 + monthlyRate, months)) / (Math.pow(1 + monthlyRate, months) - 1); const totalPayment = emi * months; const totalInterest = totalPayment - principal; setResult({ emi: emi.toFixed(2), totalPa...