This should be done in Java!!! Gas Mileage Program: Drivers are concerned with the mileage their automobiles get. One driver has kept track of several trips by recording the miles driven and gallons used for each tankful. Develop a Java application that will input the miles driven and gallons used (both as integers) for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all trips up to this point. All averaging calculations should produce floating-point results. Use class Scanner and sentinel-controlled iteration to obtain the data from the user. NOTE: It is not necessary to create a separate class for this exercise. You can use the main program to create this application. HINT: Below is an example of the while loop using the sentinel-controlled iteration while (miles != -1)
This should be done in Java!!!
Gas Mileage Program: Drivers are concerned with the mileage their automobiles get. One driver has kept track of several trips by recording the miles driven and gallons used for each tankful. Develop a Java application that will input the miles driven and gallons used (both as integers) for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all trips up to this point. All averaging calculations should produce floating-point results. Use class Scanner and sentinel-controlled iteration to obtain the data from the user. NOTE: It is not necessary to create a separate class for this exercise. You can use the main program to create this application.
HINT: Below is an example of the while loop using the sentinel-controlled iteration
while (miles != -1)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images