java percentage output

Can someone help me, understand why my output displays 5350% instead of 53.5%
The Miles Per Gallons is : 5,350% gallons 

Can someone see your code that produces such output?

 What is the starting mileage? : 12657
 The ending mileage is? : 13513
 The starting gallon of gas in the tank is? : 20
 The ending gallon of gas in the tank is? : 4
 The miles traveld is : 856.0 
 The ending gas usage is : 16.0
 The Miles Per Gallons is : 5,350% gallons 
 The travel cost of gas will be : $45.60
 The car  MPG rating is : Amazing!
 Do you want to continue? (Yes/No):  
Nothing we can do by seeing your output. We need to see the code to help you better.
Nothing we can do

Well, we could point out that the unit that is produced by dividing unit mile by unit gallon is mile/gallon, not some percentage of a gallon. The output is thus strange, no matter what the values are.


Edit: We probably do guess what you do wrong (without seeing your code) because we are(?) psychics. Can you read the explanation (without us writing it)?
Last edited on
Did you divide the distance traveled (856 miles) by the gas usage (16 gallons)?

856 miles / 16 gallons = 53.5 miles/gallon
Topic archived. No new replies allowed.