Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tanks of gasoline by recording miles driven and gallons used for each tank. Develop a program using a while loop that will input the miles driven and the gallons used for each tank. The program should calculate and display the miles per gallon obtained for each tank. After processing all input information, the program should calculate and print the overall miles per gallon obtained for all tanks.
#include <stdio.h>
int main() {
double total = 0, count = 0, miles_driven, gallons, miles_per_gallon;
while(1) {
printf("Enter number of miles driven(-1 to exit): ");
scanf("%lf", &miles_driven);
if(miles_driven < 0) {
break;
}
printf("Enter gallons used for tank: ");
scanf("%lf", &gallons);
miles_per_gallon = miles_driven / gallons;
printf("Miles per gallon is %lf\n\n", miles_per_gallon);
total += miles_per_gallon;
count += 1;
}
printf("\nOverall miles per gallon is %lf\n", total/count);
return 0;
}

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of...
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankful of gasoline by recording miles driven and gallons used for each tankful. Develop a C++ program that inputs the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful and print the combined miles per gallon obtained for all tankful up to this point. (Use the five-step problem solving methodology)...
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a C++ program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls....
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankful of gasoline by recording miles driven and gallons used for each tankful. Develop a C++ program that inputs the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful and print the combined miles per gallon obtained for all tankfuls up to this point.
Drivers are concerned with the mileage their automobiles get. One driver has kept track of several tankfuls of gasoline by recording the miles driven and gallons used for each tankful. Develop a C# app that will input the miles driven and gallons used (both as integers) for each tankful. The app should calculate and display the miles per gallon obtained for each tankful and display the combined miles per gallon obtained for all tankfuls up to this point. All averaging...
7.11 Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording the number of miles driven and the number of gallons used for each tankful. Develop a script that will take as input the miles driven and gallons used (both as integers) for each tankful. The script should calculate and output HTML5 text that displays the number of miles per gallon obtained for each tankful and the combined...
Use a java program that does the following:
. (10 points) Write a program as follows a. Prompt the user to input two positive integers: nl and n2 (nl should be less than n2) b. If the user enters the negative number(s), convert it/them to positive number(s) c. If nl is greater than n2, swap them. d. Use a while loop to output all the even numbers between nl and n2 e. Use a while loop to output the sum...
create an application in VISUAL BASIC that calculates a cars gas
mileage. The formula for calculating the miles that a car can
travel per gallon of gas is MPG = Miles/Gallon
In the formula MPG is miles-per-gallon, miles is the number of
miles that can be driven on a full tank of gas, and gallons is the
number of gallons that the tank holds.
The applications form should have TextBox controls that let the
user enter the number of gallons...
I need trying to figure out how I can make create a code in
Python with this exercise for I am having trouble doing so.
Miles Per Gallon Calculator Write a GUI program that calculates a car's gas mileage. The program's window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. When a Calculate MPG button is clicked,...
C++, Visual Studio
3. Define a class called Odometer that will be used to track fuel and mileage for an automobile. The class should have instance variables to track the miles driven and the fuel efficiency of the vehicle in miles per gallon. Include a mutator method to reset the odometer to zero miles, a mutator method to set the fuel efficiency, a mutator method that accepts miles driven for a trip and adds it to the odometer's total, and...
IN C++ Programming Problem 1: Write a program that calculates a truck's gas mileage and cost for a road trip. Be creative with the output, think of it as a “report”, give it a title at the top and use formatting where appropriate. The program should set the number of gallons of gas that the truck can hold to 31, and the number of miles it can be driving on a full tank to 651. The program should display the...