# VB.net Programming Challenge 4-pp3: Car Loan Calculator (input, if statements, type conversion)

Introduction to Programming using Visual Basic
VB.net Programming Challenge 4-pp3: Car Loan Calculator (processing input, if statements, type conversion)

In this exercise we will create a simple car loan calculator. We’ll be processing input from text boxes, use type conversion to pass correct values to our variables, and if statements to validate the input.

Write a program to analyze a car loan. The user should enter the amount of the loan, the annual percentage rate of interest, and the duration of the loan in months. When the user clicks on the button, the information that was entered should be checked to make sure it is reasonable. If bad data have been supplied, the user should be so advised. Otherwise, the monthly payment and the total amount of interest paid should be displayed. The formula for the monthly payment is

monthly payment = (p * r) / (1 – (1 + r)) ^-n

p – amount of the loan
r = monthly interest rate (annual rate divided by 12)
— number between 0 and 100 (0% to 100%)
n = duration of the loan in months.

Formula for total interest paid is

total interest = n * (monthly payment) – p

Learning to code? Follow my VB tutorials for beginners. I do a lot of Visual Basic programming challenges and VB.net projects as part of my homework – every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don’t forget to subscribe, as I release new programming videos every day!