Please send questions to st10@humboldt.edu .
#include <iostream>
#include <iomanip> 
using namespace std;

// p. 48: "The format of numbers displayed by cout can be 
//    controlled
// by field width manipulators included in the output stream"

int main()
{
    // declaration section
    int   val1, val2, val3;
    char  dummy;   // to help with "pausing" the 
                   //    results on-screen

    // what 3 integers should be summed?
    cout << "type in 3 integers <= 9999 separated by blanks,"
         << endl;
    cout << "typing Enter after the third integer:" << endl;
    cin >> val1 >> val2 >> val3;

    // so far, we wouldn't know how to output the numbers in
    // a column, followed by their sum, "nicely";
    // ugly, hmm?

    cout << endl;
    cout << "NOT USING setw():" << endl;
    cout << "------------------" << endl;
    cout << "  " << val1 << endl;
    cout << "  " << val2 << endl;
    cout << "  " << val3 << endl;
    cout << "+ -----" << endl;
    cout << "  " << (val1+val2+val3) << endl;

    cout << endl << "type any letter to continue: ";
    cin >> dummy;

    // prettier way to display the numbers and their sum in
    // a column, using setw()!

    cout << endl << endl;
    cout << "USING setw():" << endl;
    cout << "--------------" << endl;
    cout << setw(7) << val1 << endl;
    cout << setw(7) << val2 << endl;
    cout << setw(7) << val3 << endl;
    cout << "+ -----" << endl;
    cout << setw(7) << (val1+val2+val3) << endl;

    cout << endl << "type any letter to continue: ";
    cin >> dummy;

    // demonstrating that, sadly, you cannot simply put
    // the setw(7) once --- it must be done again before
    // each value to have the desired field width

    cout << endl << endl;
    cout << "using just ONE setw():" << endl;
    cout << "-----------------------" << endl;
    cout << setw(7) << val1 << endl;
    cout << val2 << endl;
    cout << val3 << endl;
    cout << "+ -----" << endl;
    cout << (val1+val2+val3) << endl;
    cout << endl;

    // is width() version the same in this respect?
    cout.width(7);
    cout << endl << endl;
    cout << "using just ONE cout.width(7):" << endl;
    cout << "------------------------------" << endl;
    cout.width(7);
    cout << val1 << endl;
    cout << val2 << endl;
    cout << val3 << endl;
    cout << "+ -----" << endl;
    cout << (val1+val2+val3) << endl;
    cout << endl;

    return 0;
}