setw

ok I have a program and i need the second column in my fout report to line up numbers on the decimal point. I have been playing with this all day and just can't get it. any help would be appreciated. here is what I have
1
2
3
4
5
6
7
8
9
            
            fout <<setw(15)<<left<<"Employee ID: " <<setw(15) <<timeSheet[empHrs].returnid() <<endl;;
            fout <<setw(15)<<left<< "Employee Name: "<<setw(15)<<timeSheet[empHrs].returnname()<<endl; 
            fout <<setw(15)<<left<< "Tax: " << setw(15)<<right<<tax << endl;
            fout <<setw(15)<<left<< "Insurance: " <<setw(15)<<ins << endl;
            fout <<setw(15)<< left<<"Gross Pay: " <<setw(15))<<grossPay <<endl;
            fout <<setw(15)<<left<< "Net Pay: " <<setw(15)<<netPay << endl;
            fout <<setw(15)<<""<<endl;
       

If you need more of the code to help just let me know. I can get the first column to line up but the second just doesn't want to. Thanks so much
Things to try
showpoint Forces a decimal representaion for integer values, number of decimals is dependant on precision
fixed Output in fixed point notation (rather than scientific).
setprecision(int n) Set the precision to n decimal places

You need to include the header iomanip for setprecision(n).
I belive all of the above are things you set once and remain that way until reset (IE you do not need to specify them for every line).
Topic archived. No new replies allowed.