CPSC 120B -- Assignment #1
The Economics of Hybrid Cars
Given the recent spike in the cost of gas prices, you may be
considering buying a hybrid car. We all know that hybrids use
less gas, but they also cost more to initially purchase. For this
assignment you will write a JAVA program to help you make an informed
decision about the economics of owning a hybrid vehicle. (Note-
this program may calculate the bottom line for your checkbook, but it
does not address the broader ethical questions surrounding the use
of energy consumption. Saving the planet:
Due Friday, September 22, 2005 by 4 p.m.
According to recent surveys, Hybrid owners report an average
improvement of 9 miles per gallon in feul economy. A quick
survey of the manufacturer's suggested retail prices reveals that
consumers pay an average of $5,000 more for a hybrid vehicle than a
comparably equipped gasoline-only vehicle. Moreover, the
government is offering tax incentives ($2400) to encourage people to
make the transition from gas to hybrid. In order to
balance the savings in fuel economy with the cost of ownership, one
must also make some assumptions about the cost of gas and the driving
profile of the potential buyer.
The program should meet the following requirements:
Input to the program will be:
- Number of miles driven in an average month
- Anticipated price of gas
- Anticipated gas mileage a non-hybrid car
- Size of the gas tank.
Values to compute:
- Annual amount spent on gas purchase (Non-Hybrid & Hybrid)
- Frequency of gas station visits (in weeks) (Non-Hybrid &
- Amount saved in gas expenses by purchasing Hybrid model.
- Decrease in overall number of gas station visits.
- Number of years it will take to balance the gas savings with the
cost of ownership
- For the design of this program, we are going to
assume that the impoved fuel economy, increased cost and tax incentives
are to be treated as constants. Embed comments near these
variable declarations to describe why it is appropriate to treat these
values as constants. Consider:
- How the program would be different if these values were not
treated as constants
- How this assumption affects the audience of the program - to whom
is it useful given these assumptions.
- Why are constants preferable to literals in this program.
- The tax incentive should be treated as a tax credit.
This is tantamount to a rebate on your taxes.
Output Your output must
be nicely formatted (similar to that below but you should choose
your own way of formatting) and must include the following information
appropriately labeled with white space):
- A reasonable heading, offset at least 3 lines from where the user
- The total amout of gas spent with a Non-Hybrid model
- The frequency of gas station visits for a Non-Hybrid model.
- A list of the assumptions that go into calculating the Hybrid
- The amount saved in gas expenses by purchasing a Hybrid model
- The frequency of gas station visits for a Hybrid model.
- A statement about the amount of time to balance the gas savings
with cost of ownership.
Sample Output A frun of your program may look something
like the following :
How many miles do you drive per month? _____
What is the anticipated price of gas ? _____
What is the anticipated gas mileage for your new car? _____
How big is the gas tank in your new car? ____
Hybrid Car Savings Analysis
Over the course of the year, you will spend $_____ on gas
You'll need to stop at the gas station approximately once every ____ weeks
Hybrid owners report getting an average of ___ more miles per gallon and paying $______ more.
Fortunately, there is currently a tax credit of ______
Under these conditions:
You will save ____ per year
You will only have to fill up approximately once every _____ weeks
It will take you approximately ______ years to balance the cost of ownership with the savings.
Note: the blanks in the example above will be filled with actual numbers
- You must use meaningful names for variables, constants, and
your class. Use Java conventions for case -- constants (declared
with final) are all uppercase (with the underscore separating
variables start with a lowercase letter (but each separate word
within the variable starts with a capital), the class name is
Choosing meaningful names makes your program easier to read and follow.
- Use white space (blank lines and blank spaces) in your program to
it easier to read. Separate the sections of the program with blank
lines. Indent and align your code properly (emacs helps you do this -
indents in most cases -- if a line isn't indented correctly go to it
and press TAB -- if TAB doesn't make it indent correctly you probably
a syntax error).
- Document your program. At the top you must have documentation
includes the file name, a brief description of
what the program does (this should include a list of the input expected
and the output the program will produce), the date, and your name.
- Hand In: A printed copy of your program (the source code).
- E-mail: Your source code to firstname.lastname@example.org.
Academic Integrity Reminder!!! Programming
assignments are to be your own work. You may get help on the specifics
of the assignment from no one except the instructor. You may not show
your program to anyone or look at anyone else's program or share ideas
with anyone about how to write the program.