Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a c++ program that calculates a vehicle\'s gas mileage. The program should

ID: 3841922 • Letter: W

Question

Write a c++ program that calculates a vehicle's gas mileage. The program should ask the user to enter the number of gallons of gas the vehicle can hold and the number of miles it can be driven on a full tank. It should then calculate and display the number of miles per gallon for the vehicle. Write a c++ program that calculates a vehicle's gas mileage. The program should ask the user to enter the number of gallons of gas the vehicle can hold and the number of miles it can be driven on a full tank. It should then calculate and display the number of miles per gallon for the vehicle.

Explanation / Answer

#include<iostream>

using namespace std;

int main() // create the main program

{

double capacity, miles, average; // declaring the variables for the problem

// getting the inputs for the problem

cout << "Enter the number of size of the tank (gallons): ";

cin >> capacity;

cout << "Enter the number of miles per tank of gas: ";

cin >> miles;

  average = miles/capacity; // calculate the relevant outputs for the problem

cout << "The car's MPG is: " << average << endl << endl;

system("pause");  

return 0;   // return 0 to exit the program

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote