CS 230 Spring 2007
Assignment 3 –Simple IFs
100 points
Assigned: 02/07/2007
Due: 02/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. If this program won’t be EASY for you, write pseudocode for
the main button.
Main Assignment:
A parking garage
charges a $8.00 minimum fee to park for up to 4 hours. The garage charges an
additional $1.50 per hour or each part thereof in excess of 4 hours. The
maximum basic charge is $15.00. On top of this (in addition to this), large
vehicles (vans, SUVs) are charged an extra $3.00 (thus a van that parked long
enough could be charged as much as $18.00). Write a program that gets from the
user the number of minutes spent in the garage, and whether the vehicle
is a large vehicle (Checkbox recommended), and reports the parking fee. Your
program should include a “Check Out” button that will calculate and display the total charge. In addition to the calculate
capability, provide capabilities to clear all of the controls (text
boxes and checkbox) 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 3). 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:
- Hint: In figuring out how many hours to charge for
when somebody has not stayed an even number of hours,
· Some built-in VB methods
that could be useful include Convert.toInt32 and Math.Ceiling (which finds the
largest number greater than or equal to a given number (Math.Ceiling of 5.4
would be 6). (it returns a double, so a convert to integer may also be needed).
- Hint: If you use the
above method there are 3 possible cases to handle (what are they?)
- Hint: If you branch
based on the number of minutes stayed into all possible fees, how many
cases are there to handle?
- Make sure you handle
partial hours – if the person stays 241 minutes, they pay for 5 hours.
- Define numbers
(especially those that could change sometime in the futures) as named
constants. E.g. the minimum fee, the basic cost, the number of hours you
get for that basic cost, … 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 charge
as currency.
- We’re going to assume
that the clerk enters valid and reasonable values for now, so that we’re
not taking on too many new tasks at once (Unless this is EASY for you –
don’t mess yourself up by doing extra before you get the required done)
- 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: 250 minutes for an SUV should cost $12.50.
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.