1.     Write a program that prompts the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automobile can be driven. The program outputs the number of miles the automobile can be driven without refueling.
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout<<"\nEnter the capacity of an automobile fuel tank in gallons : ";
double _automobile_fuel_tank_capacity;
cin>>_automobile_fuel_tank_capacity;
cout<<"\nEnter the miles per gallon the automobile can be driven: ";
double automobile_miles_per_gallon;
cin>>automobile_miles_per_gallon;
//Now lets calculate miles that can be driven
double number_of_miles = _automobile_fuel_tank_capacity*automobile_miles_per_gallon;
//Now print the number of miles
cout<<"\nThe number of miles the automobile can be driven without refueling = "<<number_of_miles<<" miles"<<endl;
return 0;
}
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment