Project 1, SI204, Fall 2002: Rate Tables
Your mission, whether or not you choose to accept it, is to write
a program that produces tables of data about loans. Specifically,
the user will enter a loan amount, a range of interest rates, and a
range of monthly payments. (Payments are made at the end of each
month, and interest is computed on the value the balance had at the
beginning of the month.)
Your program will produce a table
showing the duration of the loan for each of the different
interest rates and monthly payment amounts. The table will be
output in html format, which your web-browser will render nicely.
Here is a sample run of the final product we expect:
| Run of the program |
File output.html in browser |
 |
| $5 |
$15 |
$25 |
$35 |
$45 |
| 5% |
431 | 79 | 44 | 31 | 24 |
| 6% |
6327 | 82 | 45 | 31 | 24 |
| 7% |
* | 85 | 46 | 32 | 24 |
| 8% |
* | 89 | 47 | 32 | 25 |
| 9% |
* | 93 | 48 | 33 | 25 |
| 10% |
* | 98 | 49 | 33 | 25 |
|
The assignment is given to you in several steps. In each step you
add functionality to get you closer and closer to the final
program demonstrated above. These steps are to help you!
Breaking a big program up into a sequence of programs that start
out simple and build up to the final version is a great way to
solve a difficult problem!
- Part 1
-
Write a program that reads from the user a loan amount, an
interest rate, and a monthly payment, and prints out the
duration of the loan in months. Assume that the format is
$amt rate%
$pmt, where amt is the loan
amount in dollars
(clearly!), the interest rate is an annual percentage rate
that is to be compounded monthly, and pmt is the
monthly payment amount in dollars. Remember, monthly
compounding at interest rate r% means that every
month the balance B increase to B = B*(1 + r/12).
A typical run of your program is expected to look like this:
Input: $1000.00 7.0% $35.00
Duration of loan is 32 months |
If the loan will never be paid off (i.e. interest accrues
as fast or faster than your payments) the program should print
a warning.
Hint: Solve this problem problem by
simulation, i.e. set up the balance and simulate
interest acruing and payments coming in month-by-month.
However many months it takes for the balance to make it to
zero or below, that's the duration of the loan!
- Part 2
- Write a program (really just modify your Part 1 solution!)
that reads from the user a loan amount, a range of interest
rates, and a monthly payment, and prints out the duration of
the loan at each interest rate in months.
Assume the format is
$amt
from ri% in n steps of stp%
$pmt
|
where amt is in dollars (obviously), ri is the base
interest rate, n is the integer number of steps to be
taken (and is not negative!), stp is the size (in
percentage points) of each step in the interest rate, and
pmt is the amount of the monthly payments.
Input:
$1000.00
from 6.0% in 2 steps of 2.0%
$25.00
6% 45 months
8% 47 months
10% 49 months
|
- Part 3
-
Write a program (really just modify your Part 2 solution!)
that reads from the user a loan amount, a range of interest
rates, and a range of monthly payment amounts, and prints out
the duration of
the loan in months for each interest rate - monthly payment
combination.
Assume the format is
$amt
from ri% in n steps of stp%
$pmt
|
where amt is in dollars (obviously), ri is the base
interest rate, n is the integer number of steps to be
taken (and is not negative!), stp is the is size (in
percentage points) of each step in the interest rate, and
pmt is the amount of the monthly payments. Just
print the numbers to the screen, separated by tabs. Here's a
sample run of such a program:
- Part 4
-
Write a program (really just modify your Part 3 solution!)
that solves the problem posed at the beginning of the project,
i.e.
that reads from the user a loan amount, a range of interest
rates, and a range of monthly payment amounts, and an output
file name, and writes to that file the html-code needed to
produce a table showing
the duration of
the loan in months for each interest rate - monthly payment
combination.
Assume the format is
$amt
from ri% in nr steps of stp_r%
from $pi in np steps of $stp_p
filename
|
where amt is in dollars (obviously), ri is the base
interest rate, nr is the integer number of steps to be
taken (and is not negative!), stp_r is the size (in
percentage points) of each step in the interest rate,
pi is the base
monthly payment, np is the integer number of steps to be
taken (and is not negative!), stp_p is the size (in
dollars) of each step in the monthly payment amount, and
filename is the name of the file to which the output is
to be written. All you need to know about html and html-tables
is available in HTML-Tables. The
project intoduction gave you an example of what the output
should look like.
What to turn in and when to turn it in
This project is due by close of business Monday, 23 September.
Please see the course policy for information on submission and
late policy. Please remember that programming projects are to
be exclusively your own work, unlike homeworks and labs!
Please consult the course policy and
the
C.S. Department Honor Information Webpage, and feel free to
talk to your instructor if you have any questions about what is
and isn't allowed!
You may submit a solution to exactly one of (Part 1, Part 2, Part
3 or Part 4) of
the above. Ideally you will all simply
submit a solution to Part 4, the complete assignment. Whatever
you submit, that program must work! We will not accept
submission of a project that does not compile! No matter to which
of the 4 Parts you submit a solution, your solution must
correctly read input in the format given for that part, and
produce output in the format given for that part.
You will submit to your instructor:
- A signed copy of this cover page.
- A printout of the source code (i.e. the .cpp file) for your
program. You are responsible for making sure that this
printout looks good! If lines wrap around, text is illegible,
or the printer messes up formatting, you will lose points.
Reformat to make sure these things don't happen.
- A screencapture of your program running with the following
input:
| If you submit Part 1 |
$3000.00 11.5% $55.50 |
| If you submit Part 2 |
$3000.00
from 4% in 5 steps of 2.5%
$55.50 |
| If you submit Part 3 |
$3000.00
from 4% in 5 steps of 2.5%
from $10.50 in 4 steps of $40.00 |
| If you submit Part 4 |
$3000.00
from 4% in 5 steps of 2.5%
from $10.50 in 4 steps of $40.00
table.html |
and if you are submiting Part 4, a screen capture of your
browser rendering the file table.html produced by
the above run of your program.
-
An electronic copy (via e-mail) of your source code. The file
must be e-mailed as an attachment, and it must be the same
.cpp file as the one you submit as a printout.
The project is not deemed to have been submitted until both
parts have been submitted.
Grading
Remember, you may submit a solution to only one of the 4 "parts"
of the project.
A "Part 1" submission is worth a maximum of 30 points. A "Part 2"
submission is worth a maximum of 60 points. A "Part 3" submission
is worth a maximum of 80 points. A "Part 4" submission is worth a
maximum of 100 points. Grading of your submission is up to the
discretion of your instructor.
Christopher W Brown
Last modified: Fri Sep 13 07:50:22 EDT 2002