CS 107 - Summer 2015

Lab Assignment 5

Due: Friday 7/17/15 at 11:59pm

Write a C++ Program (using only the C+ subset as defined in lecture) that will:

  1. Print out your name
  2. Print out your net-id
  3. Print out CS 107 and Semester information (Summer 2015)
  4. Print our the Assignment Name and Number (Lab Assignment 3)
  5. Print out your lab time (Wednesday at 10am)
  6. Print out the additional information as described below:
Lumber Yard Cost Calculator

For this lab assignment, you are to write a C++ program that will determine the total cost of a lumber order.

Lumber is priced by "board feet". One "board foot" equals one square foot of wood that is one inch thick. However, different types of wood cost different amounts per "board foot". The lumber company sells pine, fir, cedar, maple and oak lumber. The cost per board foot for each of these types of lumber is given below.

  Lumber Type Cost per board foot
  Pine $ 0.89
  Fir $ 1.09
  Cedar $ 2.26
  Maple $ 4.50
  Oak $ 3.10
Lumber is sold in different dimensions that will need to be converted into board feet. A board that is 2x4x8 is 2 inches wide, 4 inches high and 8 feet long. To convert to board feet multiply the width (in inches) by the height (in inches) by the length (in feet) and then divide by 12.0 (you need a floating point result).

The input from the user will be a character value that may be followed by 4 integer numbers. The character values will be one of p, f, c, m, o (corresponding to the five kinds of wood) or t. When the t is given, the user wants the total of the previous lines of input (and quit the program). Also, when t is given, there will be no integers following it on the input line.

When the user enters a value of p, f, c, m or o as the first character on the input line, your program is to loop and prompt the user for another line of input.

The 4 integer values will reflect the number of pieces of lumber desired followed by the width, height and lenght of the desired lumber. For example assume the user enters:

  • p 10 2 4 8
The user wants 10 pieces of PINE that are 2 inches wide by 4 inches high by 8 feet long.

The following is an example of the input and output of the program. The items printed in BOLD text are those items entered by the user.


Enter Item: p 10 2 4 8

User ordered 10 pieces of 2x4x8 pine boards. Cost: $47.47

Enter Item: m 1 1 12 8

User ordered 1 pieces of 1x12x8 maple boards. Cost: 36.00

Enter Item: t

Total cost: $83.47

To calculate the board feet of a piece of lumber, you MUST write it as a function. The function is to take 3 integer parameters (the width, the height, and the length of the board) and is to return the board feet amount as a floating point value.

To calculate the cost of a piece of lumber, you MUST write a second function. This function is to take 2 parameters. The first parameter is a character specifying the type of wood (p, f, c, m or o). The second parameter is the board feet amount of the lumber. This function is to return the cost of that piece of lumber. Note this value (when printed) should be rounded to two decimal places. This could be done by the output formatting statement.

Submission of the Lab

The lab must be submitted electronically to the Assignment Link for Lab 5 inside of Blackboard. You will only need to submit the C++ source code file (just the ".cpp" file, not the "a.out" file).

You are to name your program file using both your NET-ID and the Lab Number. Thus for Lab 5, if you NET-ID was ptroy4, your program should be named: ptroy4Lab5.cpp

-- Main.troy - 2015-07-14

Topic revision: r1 - 2015-07-14 - 21:07:55 - Main.troy
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF