< previous page page_303 next page >

Page 303
Here is the program:
//******************************************************************
// Invoice program
// This program prints a shipping invoice given quantities,
// item descriptions, and unit prices as read from a data file
//******************************************************************
#include <iostream.h>
#include <iomanip.h>   // For setw() and setprecision()
#include <fstream.h>   // For file I/O

const int DESCR_LENGTH = 30;    //Characters in an item description

int main()
{
    int      quantity;        //Number of items ordered
    int      totalUnits;      //Total items in invoice
    int      counter;         // Loop control variable for printing
                              // description
    float    price;           // Unit price for an item
    float    amount;          //Amount for quantity of items
    float    totalAmount;     //Total amount of ivoice
    char     blank;           //Dummy variable to hold blanks
    char     inputChar;       // Holds  one character of description
    if stream inFile;         //File containing item quantities,
                              // descriptions, and prices

    cout.setf(ios::fixed,ios::floatfield);  //Set up floating pt.
    cout.setf(ios::showpoint);              //  output format
    cout << setprecision(2);

    // Print headings

    cout << setw(50) << Mill Hollow Boring and Bearing Company
         <endl;
    cout << setw(43) << 128 East Southwest Street << endl;
    cout << setw(50) << North Old Newgate, New Hampshire 01010
         < endl;
    cout << endl;
    cout << setw(38) << Shipping Invoice << endl;
    cout << endl;
    cout << Quantity << setw(22) << Description
         < setw(19) < Price < setw(11) < Amount < endl;
    cout << endl;

    // Print body of invoice

 
< previous page page_303 next page >