Assigned: Friday, January 24
Due: Thursday, January 30, 2020 by 11:55pm (on Moodle)
Description
In this project, you will write a program to calculate information about a car loan. Often a car is too expensive to purchase outright, so people will obtain a loan, by which they pay off the car over a period of years.There are a number of factors involved with a car loan. There's an initial sales price for the car, on which the buyer must pay sales tax. Often the buyer will be trading in a previous vehicle and this amount (trade-in value) is deducted from the purchase price before tax is added. Sometimes the buyer will pay some amount of money upfront, before the loan, as a down payment. This amount is deducted after tax is added. The remainder of the purchase price (the amount left over after the down payment and trade-in value is taken away) becomes the principal value of the loan (the amount that the person must borrow).
From this principal, the car buyer negotiates with a lender an interest rate for the loan and the amount of time in years over which the loan will be repaid. There is a particular formula used to calculate the monthly payment of the loan:
P ( r / 12 ) ------------------------- -m (1 - ( 1 + r / 12 ) )where P = is the principal, r = the interest rate, and m = the number of monthly payments.
Here's an example. Suppose you are interested in buying a car that costs $25,000, and sales tax is 9.25%. $25,000 is the purchase price. Say you trade-in your previous car for $3000 and put down an additional $2000 as a down payment. The total taxable amount is then $22000. Multiply this by 1.0925 to determine the amount with tax, which is $24,035.00. Then subtract your down payment amount of $2000. The remainder, $22,035.00 becomes the principal for your loan. Suppose you get a 3.5% interest rate on a 5-year loan. You must make a payment every month, which means you'll make 60 payments. The payment each month will be:
22035 ( 0.035 / 12 ) --------------------------------- -60 (1 - ( 1 + 0.035 / 12 ) )which comes out to approximately $400.86. Note that r has been converted from a percent to a decimal.
(Program begins) Welcome to the car loan calculator. Please enter the following to determine your monthly payment. Purchase price of car: 25000 Sales tax rate (enter 9.25% as 9.25): 9.25 Trade-in value: 3000 Down payment amount: 2000 The principal value of your loan will be 22035.0 Number of years loan will last: 5 Interest rate of loan: 3.5 You will make 60 payments of 400.8551004195982 Over 5 years, this will be a total of 24051.306025175894 (Program ends)
(Program begins) Welcome to the car loan calculator. Please enter the following to determine your monthly payment. Purchase price of car: 15000 Sales tax rate (enter 9.25% as 9.25): 6.5 Trade-in value: 2500 Down payment amount: 1000 The principal value of your loan will be 12312.5 Number of years loan will last: 7 Interest rate of loan: 5.5 You will make 84 payments of 176.93115014527436 Over 7 years, this will be a total of 14862.216612203047 (Program ends)Your code does not need to follow this script verbatim, but all the mentioned functionality should work as shown.
How to get started
Requirements
A good program will do all of the following:
Policy on challenge problems:
Your program will be graded on correctness (whether your calculations are correct), as well as on coding style, which refers to choices you make when writing your code, such as good use of variable names, appropriate indentation, and comments (this is not an exhaustive list).
You will receive one bonus point for every complete day your program is turned in early, up to a maximum of five points. For instance, if your program is due on September 20 at 11:59pm, if you turn in your code on Moodle any time on September 19 from 12:00am through 11:59pm, you will receive one extra point on your project. Programs submitted on September 18 from 12:00am through 11:59pm will receive two points. This pattern continues for up to five points.