'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 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")
Debug.Print "Entered price of the car: " & FormatCurrency(PriceOfCar, 2) & Chr$(13) _
& "Entered amount of downpayment: " & For