What can I do to make these two items print inline with the rest of the table? I have been messing with my setw but I can't figure it out.
Current output:
Part Number Part Description Quantity Price
----------------------------------------------------------------
83 Electric sander -------- 7 ------- $57.98 (added lines to show)
24 Power saw 18 $99.99
7 Sledge hammer 11 $21.50
77 Hammer 76 $11.99
39 Lawn mower 3 $79.50
68 Screwdriver 106 $6.99
56 Jig saw 21 $11.00
3 Wrench 34 $7.50
Press any key to continue . . .
Desired output:
Part Number Part Description Quantity Price
----------------------------------------------------------------
83 Electric sander 7 $57.98
24 Power saw 18 $99.99
7 Sledge hammer 11 $21.50
77 Hammer 76 $11.99
39 Lawn mower 3 $79.50
68 Screwdriver 106 $6.99
56 Jig saw 21 $11.00
3 Wrench 34 $7.50
Press any key to continue . . .
1 2 3 4 5 6 7 8 9 10 11 12 13
|
cout << "Part Number\t";
cout << setw(7) << "Part Description\t";
cout << setw(7) << "Quantity\t";
cout << setw(7) << "Price\n";
cout << "----------------------------------------------------------------\n";
for (int i = 0; i < NUM_ITEMS; i++)
{
cout << invoices[i].getNum();
cout << setw(11) << "\t" << invoices[i].getDes();
cout << setw(11) << "\t" << invoices[i].getQuan();
cout << setprecision(2) << fixed << setw(11) << "\t$" << invoices[i].getPrice() << endl;
}
|