-
What am I doing wrong?
Well, it looks right to me... but for some reason, it is not displaying the way I want it to. Here is the part of the code I am referring to:
Code:
fee=car ( calc);
cout << "You were parked for " << minutes << " minutes. You owe $" << fee << setprecision(4) << "." << endl;
As you can see, I am calling the function car () which returns a double value. I DO have fee declaread as double in the function, but it is only displaying the answer from the equations I have it go through. (Ex. ...you owe $9. instead of you owe $9.0000)
I also DO have #include <iomanip>
what am i missing?
-
Put the setprecision before the outputing the fee. And you also need to set the format to ios::fixed. And yes you need to include <iomanip>
Code:
#include <iostream>
#include <iomanip>
int main()
{
double fee = 9.00;
std::cout<<std::setiosflags(std::ios::fixed)<<std::setprecision(2)<<fee<<std::endl;
std::cin.get();
return 0;
}
-
excellent!!! so simple....
thnx again!!!!
-