'Author: Jeremy Druin 'Calculate Monthly Payment on Simple Interest Car Loan '9-13-2000 Option Explicit Sub Main() 'Declaration Dim PriceOfCar As Single Dim DownPayment As Single Dim LoanYears As Integer Dim TaxAmount As Single Dim TotalCostOfCar As Single Dim BorrowedAmount As Single Dim InterestAmount As Single Dim LoanAmount As Single Dim MonthlyPayment As Single 'Constants Const SalesTax = 0.07 '7% Const InterestRate = 0.09 '9% 'Input PriceOfCar = InputBox("Please enter the price of the car in question.", "Car Price Input Box") DownPayment = InputBox("Please enter the amount of your downpayment in dollars and cents.", "Downpayment Input Box") While LoanYears < 1 LoanYears = InputBox("Please enter the length of the loan in years. (No months, fractions, or decimals please.)") Wend 'Formulae TaxAmount = PriceOfCar * SalesTax TotalCostOfCar = PriceOfCar + TaxAmount BorrowedAmount = TotalCostOfCar - DownPayment InterestAmount = BorrowedAmount * InterestRate LoanAmount = BorrowedAmount + InterestAmount MonthlyPayment = LoanAmount / (LoanYears * 12) MsgBox ("Entered price of the car: " & FormatCurrency(PriceOfCar, 2) & Chr$(13) _
& "Entered amount of downpayme nt: " & FormatCurrency(DownPayment, 2) & Chr$(13) _ & "Entered years of loan: " & LoanYears & " year(s)" & Chr$(13) _ & "Amount of Sales Tax: " & FormatCurrency(TaxAmount, 2) & Chr$(13) _ & "Total cost of car: " & FormatCurrency(TotalCostOfCar, 2) & Chr$(13) _ & "Amount of borrowed money: " & FormatCurrency(BorrowedAmount, 2) & Chr$(13) _ & "Amount of interest on this loan: " & FormatCurrency(InterestAmount, 2) & Chr$(13) _ & "Total amount of your loan: " & FormatCurrency(LoanAmount, 2) & Chr$(13) _ & Chr$(13) _ & "Your monthly payment will be: " & FormatCurrency(MonthlyPayment, 2) & " per month") Debug.Print "Entered price of the car: " & FormatCurrency(PriceOfCar, 2) & Chr$(13) _ & "Entered amount of downpayment: " & FormatCurrency(DownPayment, 2) & Chr$(13) _ & "Entered years of loan: " & LoanYears & " year(s)" & Chr$(13) _ & "Amount of Sales Tax: " & FormatCurrency(TaxAmount, 2) & Chr$(13) _ & "Total cost of car: " & FormatCurrency(TotalCostOfCar, 2) & Chr$(13) _ & "Amount of borrowed money: " & FormatCurrency(BorrowedAmount, 2) & Chr$(13) _ & "Amount of interest on this loan: " & FormatCurrency(InterestAmount, 2) & Chr$(13) _ & "Total amount of your loan: " & FormatCurrency(LoanAmount, 2) & Chr$(13) _ & Chr$(13) _ & "Your monthly payment will be: " & FormatCurrency(MonthlyPayment, 2) & " per month" End Sub
Immediate Window Output: Entered price of the car: $30,000.00 Entered amount of downpayment: $10,000.00 Entered years of loan: 5 year(s) Amount of Sales Tax: $2,100.00 Total cost of car: $32,100.00 Amount of borrowed money: $22,100.00 Amount of interest on this loan: $1,989.00 Total amount of your loan: $24,089.00 Your monthly payment will be: $401.48 per month