CMPS 134 Fall 2025
Programming Assignment #2: Car Loan Estimator
Due Time/Date: 11:59pm, Wednesday, Sept. 24

Background

In all likelihood you will (if you have not already) encounter the need to finance the purchase of some expensive item, such as an automobile. The marketing you may face can be confusing and so there is value in being able to readily determine the monthly cost of such financing.

Specification

For this assignment you are to complete the given Java class CarLoanEstimator (two of whom's methods are stubs) so that it produces output such as illustrated below:

Monthly payments for a $25000.00 loan
   ||    1.00 % |    2.00 % |    3.00 % |    4.00 % |    5.00 % |    6.00 % |    7.00 % |    8.00 % |    9.00 % |   10.00 % |  
---||-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
12 ||   2094.64 |   2105.97 |   2117.34 |   2128.75 |   2140.19 |   2151.66 |   2163.17 |   2174.71 |   2186.29 |   2197.90 |  
24 ||   1052.55 |   1063.51 |   1074.53 |   1085.62 |   1096.78 |   1108.02 |   1119.31 |   1130.68 |   1142.12 |   1153.62 |  
36 ||    705.20 |    716.06 |    727.03 |    738.10 |    749.27 |    760.55 |    771.93 |    783.41 |    794.99 |    806.68 |  
48 ||    531.54 |    542.38 |    553.36 |    564.48 |    575.73 |    587.13 |    598.66 |    610.32 |    622.13 |    634.06 |  
60 ||    427.34 |    438.19 |    449.22 |    460.41 |    471.78 |    483.32 |    495.03 |    506.91 |    518.96 |    531.18 |  
72 ||    357.89 |    368.76 |    379.84 |    391.13 |    402.62 |    414.32 |    426.23 |    438.33 |    450.64 |    463.15 |  
Done!!

Note that this application program takes no input, but instead produces —with respect to a loan for a hard-coded value of $25,000— a terse tabular output where the column headings indicate the annual interest rate and the row headings indicate the term (i.e., duration), measured in months. The cell entries show the corresponding computed monthly payment sufficing to pay off the loan. For example, the table indicates that, at a 1% annual interest rate, twelve monthly payments of $2,094.64 (totaling $25,135.68) suffice to pay off the loan, while seventy-two monthly payments of $357.89 (totaling $25,768.08) would be sufficient. Thus, in the first case it costs an extra $135.68 to own the vehicle and in the second case it costs an extra $768.08. Meanwhile, at a 10% annual interest rate, if one were to make seventy-two monthly payments of $463.15 (totaling $33,346.80), it would cost an extra $8,346.80 to own the vehicle!

The formula used to compute the monthly payment is explained in detail in this video.


The System.out.printf() Method

You will notice that the given program makes use of the method System.out.printf(). This method, like System.out.println(), is a "standard" method, but it provides more control over the appearance of the resultant string to be printed. This is particularly useful when printing a table, since it is required that the columns be uniformly aligned for the sake of readability. The printf() method is introduced and briefly described starting on page 274 (in Secton 4.3) of the Reges & Stepp textbook. Of course, more detailed explanations with examples maybe found online, including this one.


Submission of Program

Submit your source code file (which must be named CarLoanEstimator.java) to the appropriate Brightspace dropbox. Do not submit the associated .class file.

The program that was provided to you (see link above) includes a comment describing the purpose/behavior of the program; a comment identifying the course, semester, and assignment number; and comments intended to identify the program's author (you!) and those with whom you collaborated in completing the program. Also included is a comment intended for you to describe any known defects of your program. Consider this to be a template that you are expected to follow in all subsequent assignments.