Answer:
Step-by-step explanation:
The following is written in C++ and asks the user for inputs in both miles/gallon and dollars/gallon and then calculates the gas cost for the requested mileages using the input values
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
// distance in miles
float distance1 = 20.0, distance2 = 75.0, distance3 = 500.0;
float miles_gallon, dollars_gallon;
cout << "Enter cars miles/gallon: "; cin >> miles_gallon;
cout << "Enter cars dollars/gallon: "; cin >> dollars_gallon;
cout << "the gas cost for " << distance1 << " miles is " << fixed << setprecision(2) << (float) dollars_gallon * distance1 / miles_gallon << "$\\";
cout << "the gas cost for " << distance2 << " miles is " << fixed << setprecision(2) << (float) dollars_gallon * distance2 / miles_gallon << "$\\";
cout << "the gas cost for " << distance3 << " miles is " << fixed << setprecision(2) << (float) dollars_gallon * distance3 / miles_gallon << "$\\";
return 0;
}