CS 230 Spring 2005

Assignment 2 –Simple GUI and Simple Calculations

100 points

 

Assigned: 01/31/2005

Due: 02/07/2005 at the start of class

 

Pre-Lab (Do Before Lab):  Bring a new disk. Plan out tasks, objects, and events needed for program.

 

Main Assignment:

We are writing a program to help a driver keep track of their car expenses for a trip, focusing on gas costs.  Your program will need to get from the user the number of gallons of gas purchased, the price per gallon paid for the gas, the odometer reading when the tank was full, and the odometer reading when refilling the tank.  For your variable types, choose the type that fits the possible values – if a value can ever have a decimal value, use double. Your program should include a “Calculate” button that will calculate and display the miles traveled, the miles per gallon, the total amount paid for gas, and the cost per mile driven. To keep your job simple for this early in the class, we will assume that the order-entry typist is infallible.  In addition to the calculate capability, provide capabilities to clear all of the text boxes to start again, and to exit.

 

Hand in:

To avoid needless long waits, I recommend doing this on the c: or other drive, then upon completion, copying it to the a: drive, testing it there, and creating an extra backup for yourself.

 

Miscellaneous:

This program is simplified because there are things we haven’t covered yet. For instance, we assume that the gas tank is full when we start, and that the trip only requires a fill-up at the end of the trip.

 

Note that we haven’t done anything yet with making sure the user enters something reasonable – don’t worry about that – we’re assuming that the user knows what to do, and makes no mistakes.

 

Format outputs involving money to show currency. To show an extra decimal place for cost per mile, use “c3” instead of “c”.

 

Make outputs “Read Only” so the user cannot change the calculated results.

 

You must turn on Option Explicit and Option Strict.

 

MAKE SURE YOUR PROGRAM WORKS! (i.e. gets the correct answers).  It should run on any inputs (that shouldn’t be much of a problem with this straightforward a program, but make sure it handles decimals anywhere it should).

 

Put YOUR NAME, and e-mail address, date and purpose in comments at the beginning of the program.

 

You MUST include comments that explain your program in order to get full credit.

 

Put your name on the form as a Label or as part of the form title.

 

Try to use good user interface design.