java percentage output

Apr 14, 2016 at 6:22am
Can someone help me, understand why my output displays 5350% instead of 53.5%
The Miles Per Gallons is : 5,350% gallons 

Apr 14, 2016 at 6:24am
Can someone see your code that produces such output?
Apr 14, 2016 at 6:26am

 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):  
Apr 14, 2016 at 7:02am
Nothing we can do by seeing your output. We need to see the code to help you better.
Apr 14, 2016 at 7:11am
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 Apr 14, 2016 at 7:27am
Apr 14, 2016 at 7:12am
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.