CS 230 Spring 2007
Assignment 4 –More Branching
100 points
Assigned: 02/14/2007
Due: 02/21/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. If this program won’t be EASY for you, write pseudocode for
the main button.
Main Assignment:
The NJ State
Police are working on a new program in conjunction with the EZ Pass system.
This program is a simplification. The program should get from the user the
number of minutes spent on the highway, the number of miles traveled, and
the speed limit on the stretch of the Garden State Parkway traveled - (in real
life these would be obtained via the scanning process)). The program should
then display the speed and if the person was speeding the program should then
calculate the fine (see details below). Your program should include a “Submit”
button that will calculate the speed and
fine (if applicable) and display the speed and fine (if applicable). In
addition to the calculate capability, provide capabilities to clear all of the
controls 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 4). Use Windows to copy the whole folder,
instead of trying to “Save As”.
- Print out of your code. Avoid printing the code generated
from the visual creation of the form.
Task Details:
·
The schedule for fines is as follows:
o
On or under speed limit - no fine
o
less than or equal to 5 mph over the limit - $20 fine
o
more than 5 mph and less than or equal to 10 mph over the speed
limit - fine is $20 plus $2 for each mph over the speed limit.
o
more than 10 mph and less than or equal to 20 mph over the speed
limit - fine is $20 plus $4 for each mph over the speed limit.
o
more than 20 mph over the speed limit - fine is $50 plus $5 for
each mph over the speed limit.
o
If the speed limit on the stretch of highway is 65 or higher,
then the above fines are DOUBLED.
- Define numbers
(especially those that could change sometime in the futures) as named
constants. E.g. the basic fine, … all should be declared as constants to
make it easy to implement “revenue enhancements.”
- Note that we have now
covered specifying how many decimal places to display – display the speed
with one digit after the decimal point and the fee as currency.
- We’re no longer going
to assume that the clerk enters valid and reasonable values. Ensure that
the number of minutes, number of miles, and speed limit are numeric, and
that the number of miles and minutes are positive and the speed
limit is no lower than 35, and no higher than 70. 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 – so the program must be tested on more inputs to ensure
that all paths through the program code work!). One example to get you
started: 70 miles in 60 minutes where the speed limit is 65 mph, would
result in a Speed = 70.0 and a Fine = $40.
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, and indent to show the structure of the program
(VB usually does this correctly).
- Name all textboxes and
buttons meaningfully, and use conventions for starting their names.
- Make textboxes 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.