How can you print the headings:
Description Qty Price Total
so that
- "Description" is left justified in a field of 25 character positions
- "Qty", "Price" and "Total" are each one right justifed in a field of 10 character positions.
- include <iomanip>
- Use cout << setw(25) to cause the next item output be in a field of 25 character positions
- cout.setf(ios::left, ios::adjustfield) causes an item that needs fewer character positions than the field to be placed in the left most positions (and padded with the fill character, i.e., blanks)
- cout.setf(ios::right, ios::adjustfield) causes an item that needs fewer character positions than the field to be placed in the right most positions (and padded with the fill character, i.e., blanks)
cout.setf(ios::left, ios::adjustfield); cout << setw(15) << "Description"; cout.setf(ios::right, ios::adjustfield); cout << setw(10) << "Qty" << setw(10) << "Price" << setw(10) << "Total" << endl;