Here is my code....
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,d;
cout << "Previous odometer reading: ";
cin >> a;
cout << "New odometer reading: ";
cin >> b;
cout << "Gallons added to the tank to fill: ";
cin >> c;
d = (b - a)/c;
cout << fixed << setprecision(2);
cout << "Car got " << d << " miles per gallon on last tank of gas. \n" << endl;
return 0;
}
/*
Previous odometer reading: 10543
New odometer reading: 10941
Gallons added to the tank to fill: 11.2
Car got 36 miles per gallon on last tank of gas.
Press any key to continue . . .
*/
The result supposes to be like this "Car got [B]35.45[/B] miles per gallon on last tank of gas". Although I have already setprecision(2), the ouput didn't show up. I don't know what is wrong with my code. Any comment ???