CAR LOAN CALCULATOR
def calculate_emi(principal, annual_rate, years):
monthly_rate = annual_rate / (12 * 100) # annual to monthly interest
months = years * 12
if monthly_rate == 0:
emi = principal / months
else:
emi = principal * monthly_rate * ((1 + monthly_rate) ** months) / ((1 + monthly_rate) ** months - 1)
return emi
def car_loan_calculator():
print("🔢 Car Loan EMI Calculator\n")
# Input
try:
principal = float(input("Enter loan amount (₹): "))
annual_rate = float(input("Enter annual interest rate (%): "))
years = int(input("Enter loan tenure (in years): "))
except ValueError:
print("❌ Invalid input! Please enter numeric values.")
return
# Calculations
emi = calculate_emi(principal, annual_rate, years)
total_payment = emi * years * 12
total_interest = total_payment - principal
# Output
print("\n📊 Loan Details:")
print(f"Monthly EMI: ₹{emi:.2f}")
print(f"Total Interest: ₹{total_interest:.2f}")
print(f"Total Payment (Principal + Interest): ₹{total_payment:.2f}")
# Run the calculator
car_loan_calculator()
Comments
Post a Comment