Alignment Problem Output Columns

I'm having trouble aligning the second column (prices) on my code.

1
2
3
4
5
6
7
8
9
10

cout << fixed << setprecision(2);
cout << "Currency exchange:" << "\n\n";
cout << currency_name << "-to-peso rate " << right<< setw(8) << exchange_rate << "\n\n";
cout << "peso-to-" << currency_name << " rate " << right<< setw(8) << 1 / exchange_rate << "\n\n";

cout << "Unit prices:" << "\n\n";
cout << "in " << currency_name << "s" << right << setw(8) << total_price / qty_item << "\n\n";
cout << "in pesos " << right<< setw(8) << (total_price / qty_item) * exchange_rate << "\n\n";


It looks like this:

Currency exchange:
swiss-franc-to-peso rate 5.50
peso-to-swiss-franc rate 0.18
Unit prices:
in swiss-francs 3.06
in pesos 16.83

I want to align the numbers to the right but keeping a width of 8 like the top two lines (5.50 and 0.18). Any ideas?
Last edited on
Topic archived. No new replies allowed.