I can figure this out as a math problem but I can't seem to write it as a program. I know I asked someone about this before but a "friend" crashed my computer and I've lost everything.
Write a program that calculates the miles per gallon that the user gets on her car during a vacation trip. The program should ask the user to enter the number of miles traveled and the number
of gallons of fuel consumed. The program should display the number of miles per gallon achieved on the trip.
Hello Jonathan, thanks for the question.
Programming this is no different from the math problem solution. It's the same forumla and everything. Hopefully this code sample should have you pointing in the right direction:
using namespace std;
float numMiles, numGallons
cout << "How many miles: ";
cin >> numMiles;
cout << "How many gallons: ";
cin >> numGallons;
cout << The miles per gallon achieved was "
<< numMiles / numGallons << '\n';
This should do the trick for you, if you have any other questions, please do not hesitate to ask.
I hope this information was helpful.