''' Auto Loan Payment Calculations ============================== https://www.wikihow.com/Calculate-Auto-Loan-Payments Use the formula A = P ∗ ( r ( 1 + r ) n ) / ( ( 1 + r ) n − 1 ) A = the monthly payment. P = the principal r = the interest rate per month, which equals the annual interest rate divided by 12 n = the total number of months Mass Sales Tax ============== The .0625 (6.25%) sales tax is paid in the first year only. https://www.mass.gov/guides/motor-vehicle-and-trailer-sales-and-use-tax Mass Excise Tax Fees ==================== The tax depends on the vehicle age. For this program we only calculate the excise tax on the first year of purchase. https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm ''' # ======================= Input Variables ================================== principal = 15090. rate = .07 numberOfYears = 4 # =========================================================================== rate = rate /100 ratePerMonth = rate /12 numberOfMonths = numberOfYears * 12 salesTax = principal * .0625 # Mass sales tax rate # https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm exciseTax = principal / 1000 * .9 * 25.00 monthlyPayment = principal * (ratePerMonth * (1+ratePerMonth)**(numberOfMonths))/((1+ratePerMonth)**(numberOfMonths)-1) print("The payment is ", monthlyPayment) print(f"The payment is ${monthlyPayment:.2f}") print("The sales tax is ", salesTax) print("The excise tax is ", exciseTax) print("First years expense is ", monthlyPayment*12 + salesTax + exciseTax)