CIS 636 Spring 2006 Assignment
2 – Some Basic Calculations 100 points
Assigned: 01/24/2006
Due: 01/31/2006 at the start of class
You may work individually
or in pairs for this assignment. But all work must be the work of the
person/people whose name is on the code! If working in pairs, the individual
contributions should be relatively equal. One possibility is to work together
tonight, then finish separately (to avoid communication difficulties).
Main Assignment:
We are writing a program to help America East Airline
keep track of their fuel expenses. Your program will interact with the user,
asking for the number of miles to be flown on a flight, the price per gallon
paid for the fuel, and the number of passengers on the flight. Your program expected time in the air (in hours
and seconds), the amount of fuel used, the cost for the fuel, the cost per
passenger, and the passenger miles per gallon, and will display all basic
information including the calculated information.
I would like your interaction with the user to be via
dialog boxes, using static methods from RedmondMsgInBasic and RedmondMsgOut in
my IO package. See the sample interaction below for a textual replay of what
happened in one example.
Hand in:
- Disk with an entire folder
containing the correct folder structure, your file, any other of my
classes that you use, and the corresponding Byte-code files. I should be
able to get into the IDE and run your program without any messing with
your files and folders. So test what you are handing in, even if you worked
on the hard drive and tested that in the lab.
- Print out of your code.
To avoid needless
long waits, I recommend working on this on the c: drive or jump drive, then
upon completion, copying it to the a: drive, testing it there, creating an
extra backup for yourself.
Miscellaneous:
- Some simplifying
assumptions need to be made. Assume the plane flies at a constant 600
miles per hour. Assume that fuel is used up at a constant 1.0 gallons per
second flying.
- You can get any of my IO
code you need from the assignment or review page of my WWW site. It is
written with a package statement that assumes that it is in a package of
named IO. Save it there.
- You shouldn’t have to
change anything in RedmondMsgInBasic and RedmondMsgOut. The recommended methods
make some simplifying assumptions, since we haven’t covered exception
handling yet. This means that some exceptions will result if the user
tries hard enough. Until we cover
exceptions, we won’t catch invalid values that are the wrong type
(e.g. letters where numbers are needed)). No biggie at this point.
- In using the read valid
methods in RedmondMsgInBasic, you automatically get validation. The number
of miles in the flight should be at least 50 and no more than 5000, the
price per gallon should be positive and no more than $10.00, and the
number of passengers should be at least 5 and no more than 600
- MAKE
SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors).
Try more than the below example; convince yourself that it works. Be a skeptic.
- The
example below gives nice round results. With less round results, MANY
digits after the decimal will be shown. OPTIONAL: use methods described on
my www page http://www.lasalle.edu/~redmond/teach/636/formatting.htm
to limit the number of decimal places.
- Put
YOUR NAME, and e-mail address and date in comments at the beginning of the
program.
- Also, comment any
significant code to document it.
- Indent code following
standard conventions (indent to show that something is “inside” or “part
of” the preceding code (e.g. inside if’s or loops, or statements continued
on a new line. This will not have much impact on this small program). The
IDE should handle this if you hit ENTER and move on to the next line (If
you make changes, you may need to TAB to make things right).
- Name your variables
meaningfully, to describe their use in the program.
Textual
Version of Interaction:
This
program will analyze the fuel costs for a flight, giving the cost per passenger
and passenger miles per gallon
How
many miles in the flight (whole number)?
3000
What
is the price of jet fuel (mpg)?
2.5
How
many passengers are traveling?
300
Results
Miles: 3000
MPH: 600
Hours: 5.0
Seconds: 18000.0
Gals/Sec: 1.0
Fuel Used: 18000.0
Fuel Price: 2.5
Fuel Cost: 45000.0
Passengers: 300
Cost Per Passenger: 150.0
Passenger Miles Per Gallon: 50.0