COSC 111
Programming Assignment #2
Conversions!!
We wish to contrast gasoline prices between the US and Europe.
Unfortunately (for us), most of Europe uses the Euro as their currency
and measures liquids in liters. No problem...we have the exchange
rates. As of this writing:
1 gallon = 3.7854118
liters (I don't think this will change much)
1 Euro = ???? Look this up !!
So far, so good. We can get the prices of gasoline (or petrol to you
Europeans) at : http://www.fuel-prices-europe.info/
Please note that we are only interested in the countries listed at the
top tht use the Euro.
Question: What is the price in dollars per gallon of gasoline in the
following Euro zone countries: France, Germany, Italy, Portugal, Finland
What to do:
Write a complete Java class file called Convert.java that will ask the
user to input two quantities: the number of liters bought and the price
per liter in Euros. The program will then output the corresponding
number of gallons and the cost per gallon in dollars. For example:
Enter number of liters:
<Computer program output this>
10
<user entered 10 >
Enter price per liter in
Euros
<Computer program output this>
1.32
<user entered 1.32 >
You purchased 2.6417205 gallons
<Computer output this number>
You paid $6.0460597 per
gallon <Computer output this number>
-Your program will need to employ the Scanner class.
-All numeric variables should be declared double and
have descriptive variable names.
-All variable names should begin in lower case
letters and follow the conventions used in your book
-You must use final
declarations for all conversion facts
- Don't forget to use the proper header and
description
- Note that your answers may not appear as pretty as
the ones given above
What to hand in:
You should hand in a listing of Convert.java. Do not forget to answer
the question given above; you should hand write a table with the answers on your
listing. You will demo the program to us in class.