Thread: Java assignment
View Single Post
  #1 (permalink)  
Old November 29th, 2005, 08:26 AM
greeny greeny is offline
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java assignment

I need help creating a java program, please help im stuck

2. Write a program which will:
• prompt for and read in from the keyboard the current price of a litre of petrol; and
• calculate and display the corresponding price of a gallon of petrol (1 gallon = 4.55 litres);
• prompt for and read in the total cost of filling a car with petrol; and
• calculate and display the number of gallons required ; [Hint: Divide the cost by the price per gallon; if the car takes £22 worth of petrol and petrol is £4 per gallon then that gives 5.5 gallons]
• prompt for and display the number of miles covered since the previous fill; and
• calculate and display the average petrol consumption in miles per gallon; [Hint: Divide the mileage by the number of gallons]

You must use the conversion 1 gallon = 4.55 litres within your program; any other conversion factor used will be penalised.


Reply With Quote