C++ Question how do I use fixed point notation

Hello, I am new to C++ but so far I love it! I've never programmed before but I am a computer science major and I am enjoying it so far. I had one question though that I can't seem to figure out. How to I make a cout result of an equation come out to be a fixed-point notation with two decimal points? I need to make sure the decimal point is always displayed. Here is the program I have written so far:

//This program will calculate the revenue earned from a sporting even
#include <iostream>
using namespace std;

int main()
{
int aSold, bSold, cSold;
float aRev, bRev, cRev, trev;
const float APRICE = 15.00, BPRICE = 12.00, CPRICE = 9.00;

cout << "How many tickets were sold in class A? \n"; //ask user to enter how many tickets were sold from an event
cin >> aSold;
cout << "Class b?\n";
cin >> bSold;
cout << "Class C?\n ";
cin >> cSold;

aRev = aSold * APRICE; //The process done to calculate ticket revenue
bRev = bSold * BPRICE;
cRev = cSold * CPRICE;

trev = aRev + bRev + cRev;

cout << "The total ticket sales were $" << trev << endl;

return 0;
}


When I enter sample numbers in I get $270 but what I really need it to show is $270.00 Can anyone help? What am I missing?
Use setprecision and fixed.
When post code use code tags [c0de][/c0de]
okay thx ne555
note that setprecision works for the total amount of numbers in the value (so not only for the decimals)... So if you want to show 270.00 you'll have to use setprecision(5);

See http://www.cplusplus.com/reference/iostream/manipulators/setprecision/ and http://www.cplusplus.com/reference/iostream/manipulators/fixed/ for more info on setprecision and fixed :)
Okay cool thank you Kaduuk have not had a chance to try it out yet been setting up new computer but I am going to get on it within the hour I'll let you guys know how it went
Topic archived. No new replies allowed.