< previous page page_229 next page >

Page 229
//******************************************************************
// LumberYard program
// This program reads a letter and four integer numbers.  If
// the letter is L, the four numbers are interpreted as the
// dimensions and quantity ordered of a lumber item, and the
// board-foot equivalent is output.  If the letter is P, the
// four numbers are the dimensions and quantity ordered of a
// plywood item, and the full-sheet equivalent is output.
//******************************************************************
#include <iostream.h>
#include <iomanip.h>   // For setprecision()

const float BOARD_FT_INCHES = 144.0;    // Cubic inches in
                                        //   one board foot
const float PLYWOOD_INCHES = 4608.0;    // Cubic inches in
                                        //   one plywood sheet
const int  WIDTH_INCHES = 48;           // Width in inches of
                                        //   plywood sheet
int main()
{
    char  code;            // Indicates lumber or plywood item
    long  sizel;           // First dimension
    long  size2;           // Second dimension
    long  size3;           // Third dimension
    long  numOrdered;       // Number ordered
    float boardFeet;       // Result for lumber item
    float fullSheets;      // Result for plywood item

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

    // Get data

    cout << Enter letter code, three integer dimensions, 
         < and quantity ordered: < endl;               // Prompt
    cin >> code >> sizel >> size2 >> size3 >> numOrdered;

    cout << For the order data: < endl;
    cout << code <   < size1 <   < size2 <  
         < size3 <   < numOrdered < endl;        // Echo print

    if (code == L)
    {
        // Calculate lumber amount

        boardFeet =  float(sizel * size2 * size3 * 12 * numOrdered)
                     / BOARD_FT_INCHES;
        cout << the board-foot equivalent is 
             < setprecision(2) < boardFeet < endl;
    }

 
< previous page page_229 next page >