Need help with code for data type in function

My question is what data type should I use to get the miles_per_gallon to show only four decimal places? I have tried int, double, and float and they all give
#include<iostream>

using namespace std;

int main()


{
double miles;
double liters;
double gallons;
double miles_per_gallon;
int again;

// start loop
do
{
cout << "Enter the amount of gasoline in liters:";
cin >> liters;

cout << "Enter the number of miles traveled:";
cin >> miles;



// function definition
gallons = (0.264179 * liters);
miles_per_gallon = (miles/gallons);

// display output

cout << "The gas mileage of this travel is " << miles_per_gallon <<

cout << " miles per gallon "
<< endl;

cout << "Do you want to run this program again (yes=1, no=2)? ";
cin >> again;


// end loop
}while (again == 1);


system("PAUSE");
return EXIT_SUCCESS;}
it looks like that is what i need, where do i put it in the code?
That page has an example.
Topic archived. No new replies allowed.