< previous page page_304 next page >

Page 304
    // Initialize process

    totalUnits = 0;
    totalAmount = 0.0;

    // Initialize ending condition

    inFile.open(invoice.dat);
    if ( !inFile )
    {
       cout << ** Can't open input file ** << endl;
       return 1;
    }
    inFile >> quantity;

    while (quantity > 0)
    {
        // Update process

        cout << setw(6) << quantity;

        // Read and print description

        inFile.get(blank);                // Discard extra blank
        cout <<     ;
        counter = 1;                      // Initialize loop control
                                          // variable
        while (counter <= DESCR_LENGTH)
        {
            inFile.get(inputChar);        // Process
            cout << inputChar;
            counter++;                    // Update loop control
        }                                 // variable

        inFile >> price;
        cout << setw(10) << price;
        amount = quantity * price;
        cout << setw(12) < amount << endl;
        totalUnits = totalUnits + quantity;
        totalAmount = totalAmount + amount;

        // Update ending condition

        inFile >> quantity;
    }

 
< previous page page_304 next page >