Question: Write a program that asks the user to enter the vehicle information, number-of-miles-driven and gallons-of-gas-used, then calculates the cars miles-per-gallon (MPG) and prints the result.

  1. Write a program that asks the user to enter the vehicle information, number-of-miles-driven and gallons-of-gas-used, then calculates the cars miles-per-gallon (MPG) and prints the result. The program also prints a message indicating whether or not the MPG is above, or below, or equal to the national average.

The requirements are as follows: (JAVA PROGRAM)

  1. Prompt the user to input the vehicle information, miles-driven and gallons-of-gas-used
  2. If the user input is invalid, print an error message

Otherwise, calculate MPG

  1. Output the result including the vehicle information, mile-driven and gas-used
  2. If the MPG is more than 24, print a message indicating that it is above national average

Otherwise, print a message indicating that it is equal to or below national average

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!