Hey guys, I'm new at this and was wondering if someone could help. I need to calculate the average amount of gallons used per km driven but I don't know how to do it. What do I need to include in my code(below) to include an average?
I'd appreciate any advice you could provide to me :)
#include <iostream>
using namespace std;
int main()
{
double gallons;
double average;// not used yet
double distance;
double distancegallon;
cout<<"Please enter the amount of gallons used( or 0 to quit) "<<endl;
cin>>gallons;
while(gallons != 0)
{
cout<<"Please enter distance in KM"<<endl;
cin>>distance;
distancegallon = distance/gallon;
cout<<"KM/ Gallon is:"<<distancegallon<<endl;
}
return 0;
}