CS 230 Spring 2007 Assignment
6 – More Looping 100
points
Assigned: 02/28/2007
Due: 03/14/2007 at the start of class
Pre-Lab (Do Before Lab): Bring materials – a way to
save a copy for you and a copy to turn in. Plan out tasks, objects, and events
needed for program. Write pseudocode for the main button.
Main Assignment:
We’re
going to implement a credit card simulation program. Write a program that shows
month-by-month how long it takes to pay off a credit card balance when only
paying the minimum payment each month. Get from the user the amount borrowed
and the annual interest rate to be paid. Display in a
RichTextBox for each month elapsed, the number of months elapsed to that point,
the interest owed that month, the minimum payment (see below), and the new
balance (after interest has been charged and minimum payment paid). After the balance
has been paid off, display in labels or read-only textboxes the total number of
months needed to pay off the balance and the total amount paid over the course
of that time. NOTE – this task MUST be done with a loop – I need to see the
month by month results in the text box – and in order to see that, you cannot
do a single one-time calculation.
·
Provide capabilities
to simulate, clear (the inputs and outputs) to start again, and to exit.
Hand in:
- Floppy disk or CD-R with an entire folder containing all
files related to the project. Please set the name of the project to
something other than the default name (WindowsApplication1, …). It
is helpful if you use a name that identifies you as well as the assignment
(e.g. yourlastname assignment 6). Use Windows to copy the whole folder,
instead of trying to “Save As”.
- Print out of your code.
Task Details:
·
Hint: Can you use a “for
next” loop? (Do you know when you reach the top of the loop how many times it
will need to go around?)
·
The annual interest rate
should be entered as a decimal instead of a percent (this makes your job a
little easier).
·
The interest rate is annual,
but in doing your monthly calculations, you don’t get a full year’s worth of
interest in a month! Assume months are equal length to keep this simple. If
any questions, please ask!!! Your calculations need to meet the requirements
of the task.
·
The minimum payment is
determined as follows –
·
In general, the minimum
payment is enough to pay the current interest plus 1 percent of the current
balance (e.g. with $1000 owed and .12 interest rate, interest is $10, and 1% of
the balance is $10, so the minimum payment is $20)
·
However, the lowest minimum
payment allowed is $10, unless …
·
The minimum payment never is
higher than paying off the whole remaining balance.
- Define numbers
(especially those that could change sometime in the futures) as named
constants
- We’re no longer going
to assume that the clerk enters valid and reasonable values. Ensure that
the amount borrowed and the interest rate are numeric, and that the amount
borrowed is positive, and the interest rate is between .03 and .33. Don’t
try to calculate anything if bad data has been entered (display a
message).
- MAKE SURE YOUR PROGRAM
WORKS! (i.e. gets the correct answers). It doesn’t have to just run, it
needs to run correctly! It should run on any inputs (We are
now branching and looping – so the program must be tested on more inputs
to ensure that all paths through the program code work!). For instance,
does your program still do the right thing no matter how many of the
inputs are invalid? Think up some
different examples to test the program on. For each, calculate the
correct answer by hand or in Excel and see if your program gets it!
Miscellaneous
- You must turn on
Option Explicit and Option Strict.
- Put YOUR NAME, e-mail
address, date, and purpose of the program in comments at the beginning of
the program. The purpose should be what the program is supposed to do, not
the learning goals. Comments are indicated with a single quote (everything
after the single quote is only for humans)
- You MUST include
comments that explain your program in order to get full credit.
- Remember to use
meaningful variable names
- Remember to indent to
show the structure of the program (VB usually does this correctly).
- Name all textboxes and
buttons and the rich text box meaningfully, and use conventions for
starting their names.
- Make textboxes (and
rich text box) that user should never enter a value in (results / outputs)
“Read Only”
- Put your name on
the form as a Label or as part of the form title.
- Try to use good user
interface design. Make clear what user needs to do and what the answers
mean. Make error messages as clear and helpful as possible!