Module/Week 6 ASSIGNMENT (USER-DEFINED: SIMPLE DATA TYPES, STRING TYPES)You are working for a lumber company, and your employer would like a program that calculates the cost of lumberfor an order. The company sells pine, fir, cedar, maple, and oak lumber. Lumber is priced by board feet. One boardfoot equals one square foot that is one inch thick. The price per board foot is given in the following table:Pine0.891.09FirCedar 2.26Maple 4.50Oak3.10The lumber is sold in different dimensions (specified in inches of width and height, and feet of length) that need tobe converted to board feet. For example, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high, and 8 feet long, and isequivalent to 5.333 board feet (2 *4* 8 = 64, which when divided by 12 = 5.333 board feet). An entry from the userwill be in the form of a letter and four integer numbers. The integers are the number of pieces, width, height, andlength. The letter will be one of P, F, C, M, O (corresponding to the five kinds of wood) or T, meaning total. Whenthe letter is T, there are no integers following it on the line. The program should print out the price for each entry,and print the total after T is entered. Here is an example run:Enter item: P 10 2 4 810 2x4x8 Pine, cost: $47.47Enter item: M 1 1 12 81 1x12x8 Maple, cost: $36.00Enter 1tem: TTotal cost: $83.47Develop the program using functional decomposition, and use proper style and documentation in your code. Yourprogram must make appropriate use of value-returning functions in solving this problem. Make sure that the userprompts are clear and that the output is labeled appropriatelySubmit C++ Programming Assignment 6 by 11:59 p.m. (ET) on Monday of Module/Week 6

Question
Asked Dec 2, 2019
24 views

Module/Week 6 Assignment (User-defined: Simple Data Types, String Types)

You are working for a lumber company, and your employer would like a program that calculates the cost of lumber for an order. The company sells pine, fir, cedar, maple, and oak lumber. Lumber is priced by board feet. One board foot equals one square foot that is one inch thick. The price per board foot is given in the following table:

 

The lumber is sold in different dimensions (specified in inches of width and height, and feet of length) that need to be converted to board feet. For example, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high, and 8 feet long, and is equivalent to 5.333 board feet (2 * 4 * 8 = 64, which when divided by 12 = 5.333 board feet). An entry from the user will be in the form of a letter and four integer numbers. The integers are the number of pieces, width, height, and length. The letter will be one of P, F, C, M, O (corresponding to the five kinds of wood) or T, meaning total. When the letter is T, there are no integers following it on the line. The program should print out the price for each entry, and print the total after T is entered. Here is an example run:

 

Develop the program using functional decomposition, and use proper style and documentation in your code. Your program must make appropriate use of value-returning functions in solving this problem. Make sure that the user prompts are clear and that the output is labeled appropriately.

 

Submit C++ Programming Assignment 6 by 11:59 p.m. (ET) on Monday of Module/Week 6.

 

 

Module/Week 6 ASSIGNMENT (USER-DEFINED: SIMPLE DATA TYPES, STRING TYPES)
You are working for a lumber company, and your employer would like a program that calculates the cost of lumber
for an order. The company sells pine, fir, cedar, maple, and oak lumber. Lumber is priced by board feet. One board
foot equals one square foot that is one inch thick. The price per board foot is given in the following table:
Pine
0.89
1.09
Fir
Cedar 2.26
Maple 4.50
Oak
3.10
The lumber is sold in different dimensions (specified in inches of width and height, and feet of length) that need to
be converted to board feet. For example, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high, and 8 feet long, and is
equivalent to 5.333 board feet (2 *4* 8 = 64, which when divided by 12 = 5.333 board feet). An entry from the user
will be in the form of a letter and four integer numbers. The integers are the number of pieces, width, height, and
length. The letter will be one of P, F, C, M, O (corresponding to the five kinds of wood) or T, meaning total. When
the letter is T, there are no integers following it on the line. The program should print out the price for each entry,
and print the total after T is entered. Here is an example run:
Enter item: P 10 2 4 8
10 2x4x8 Pine, cost: $47.47
Enter item: M 1 1 12 8
1 1x12x8 Maple, cost: $36.00
Enter 1tem: T
Total cost: $83.47
Develop the program using functional decomposition, and use proper style and documentation in your code. Your
program must make appropriate use of value-returning functions in solving this problem. Make sure that the user
prompts are clear and that the output is labeled appropriately
Submit C++ Programming Assignment 6 by 11:59 p.m. (ET) on Monday of Module/Week 6
help_outline

Image Transcriptionclose

Module/Week 6 ASSIGNMENT (USER-DEFINED: SIMPLE DATA TYPES, STRING TYPES) You are working for a lumber company, and your employer would like a program that calculates the cost of lumber for an order. The company sells pine, fir, cedar, maple, and oak lumber. Lumber is priced by board feet. One board foot equals one square foot that is one inch thick. The price per board foot is given in the following table: Pine 0.89 1.09 Fir Cedar 2.26 Maple 4.50 Oak 3.10 The lumber is sold in different dimensions (specified in inches of width and height, and feet of length) that need to be converted to board feet. For example, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high, and 8 feet long, and is equivalent to 5.333 board feet (2 *4* 8 = 64, which when divided by 12 = 5.333 board feet). An entry from the user will be in the form of a letter and four integer numbers. The integers are the number of pieces, width, height, and length. The letter will be one of P, F, C, M, O (corresponding to the five kinds of wood) or T, meaning total. When the letter is T, there are no integers following it on the line. The program should print out the price for each entry, and print the total after T is entered. Here is an example run: Enter item: P 10 2 4 8 10 2x4x8 Pine, cost: $47.47 Enter item: M 1 1 12 8 1 1x12x8 Maple, cost: $36.00 Enter 1tem: T Total cost: $83.47 Develop the program using functional decomposition, and use proper style and documentation in your code. Your program must make appropriate use of value-returning functions in solving this problem. Make sure that the user prompts are clear and that the output is labeled appropriately Submit C++ Programming Assignment 6 by 11:59 p.m. (ET) on Monday of Module/Week 6

fullscreen
check_circle

Expert Answer

Step 1

C++ Source Code

//include the required header files

#include<iostream>

#include <iomanip>//used for setprecision(2)

using namespace std;

//prototyoe of the function

float calculateFeet(int w,int h,int l);

//definition of main() function

int main()

{

    //declare the required variables

    char ch;

    float total=0,cost=0;

    cout <<setprecision(2) <<fixed;//to fix the float values to a precision to 2

    //execute the while loop until the value of character variable is not 'T'

    while(true)

    {

        cout<<"Enter item: ";

        cin>>ch;// get the input(char type) from the user

        if(ch!='T')

        {

            int piece,width,height,length;

            //get the input from the user for number of pieces and its dimensions

            cin>>piece;

            cin>>width;

            cin>>height;

            cin>>length;

            //according to the user input of char type, the lumber case will be executed and the function calculateFeet() will be called.

            switch(ch)

            {

              case 'P':

              cost = (0.89 * piece * calculateFeet(width,height,length));

              //print statement to display the desired output as shown in sample output

              cout<<piece<<" "<<width<<"x"<<height<<"x"<<length<<" "<<"Pine,"<<" cost: "<<"$"<<cost<<" ";

              break;

              case 'F':

              cost = (1.09 * piece * calculateFeet(width,height,length));

              //print statement to display the desired output as shown in sample output

              cout<<piece<<" "<<width<<"x"<<height<<"x"<<length<<" "<<"Fir,"<<" cost: "<<"$"<<cost<<" ";

              break;

              case 'C':

              cost = (2.26 * piece * calculateFeet(width,height,length));

              //print statement to display the desired output as shown in sample output

              cout<<piece<<" "<<width<<"x"<<height<<"x"<<length<<" "<<"Cedar,"<<" cost: "<<"$"<<cost<<" ";

              break;

              case 'M':

              cost = (4.50 * piece * calculateFeet(width,height,length));

              //print statement to display the desired output as shown in sample output

              cout<<piece<<" "<<width<<"x"<<height<<"x"<<length<<" "<<"Maple,"<<" cost: "<<"$"<<cost<<" ";

              break;

              case 'O':

              cost = (3.10 * piece * calculateFeet(width,height,length));

              //print statement to display the desired output as shown in sample output

              cout<<piece<<" "<<width<<"x"<<height<<"x"<<length<<" "<<"Oak,"<<" cost: "<<"$"<<cost<<" ";

              break;

            }

          total += cost;//add cost to total

        }

        //if user input char 'T' then print total cost and exit

        else

        {

          //print statement to display the total cost when the user input char 'T'

          cout<<"Total cost: $"<<total<<" ";

          break;

        }

    }

return 0;

}//end of main() function

//definition of the called function

float calculateFeet(int w,int h,int l)

{

  float feet = ((w*h*l)/12.0);

  return feet;

}

 

Step 2

Screenshot 1

help_outline

Image Transcriptionclose

//include the required header files #include<iostream> #include <iomanip>//used for setprecision (2) using namespace std /prototyoe of the function float calculateFeet (int w,int h,int 1); //definition of main () function int main) //declare the required variables char ch; oat total-e,cost- ; cout <<setprecision (2) <<fixed;//to fix the float values to a precision to 2 //execute the while loop until the value of character variable is not T while(true) cout<<"Enter item: "; cin>>ch;// get the input(char type) from the user if(ch!-T') { int piece,width, height, length; //get the input from the user for number of pieces and its dimensions

fullscreen
Step 3

Screenshot 2

...
help_outline

Image Transcriptionclose

cin>piece; cinwidth; cin>>height; cin>length; //according to the user input of char type, the lumber case will be executed and the function calculateFeet() will be called switch(ch) { case P' cost (e.89 piece * calculateFeet (width, height,length)); //print statement to display the desired output as shown in sample output cout<<piece<< "<<width<"x"<<height << "x" <length<" "<"Pine, "" Cost: ""S"<<cost<<"\n"; break; case F' cost (1.09* piece calculateFeet (width, height,length)); /print statement to display the desired output as shown in sample output cout<<piecec< "<<width<<"x"<<height <<"x" <length<<" "<<"Fir, "<" cost: "<"$"<<cost<"\n";

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: While searching a web database for a hotel room for an upcoming trip, a message is displayed stating...

A: This question is related to internet search where user get the pop message of “No Search Results” wh...

question_answer

Q: What are the SQL query commands (does not need to be on a platform, just need to verify the query co...

A: SQL query commands to create tables:To create table “COURSE” with “COURSE_TYPE” as primary key,CREAT...

question_answer

Q: In c++ i have a .dat file tha contains the following 123-45-6789 Kirk James 44.7 88.99 0.0175 124-89...

A: Overtime is calculated when working hours are more than 40. For each extra hour, the overtime pay is...

question_answer

Q: What is the SQL command for the following, using the data attached: Find the total of the balances f...

A: Writing a SQL query to display data of customers whose balance are less than their credit limits and...

question_answer

Q: The area of an arbitrary triangle can be computed using the formulaarea = √(s(s–a)(s–b)(s–c))where t...

A: The C++ program will obey the following rubrics:Importing essential header files.Declaring integer d...

question_answer

Q: How are authentication and authorization alike and how are they different. What is the relationship,...

A: Authentication is a process of proving that someone is who they are claiming to be. It lets a user r...

question_answer

Q: WHAT IS A DOUBLE SPEND PROBLEM OF DITIAL CASH TRANSACTION? HOW THE DOUBLE SPEND PROBLEM OF DIGITAL C...

A: Double spending: It means spending the same amount of money twice. Here's a good example to explain ...

question_answer

Q: Write a program whose input is a character and a string, and whose output indicates the number of ti...

A: The C++ program to count the appearance of a character present in a string by using a user-defined f...

question_answer

Q: Write a program that gets a list of integers from input, and outputs the integers in ascending order...

A: Program:#include&lt;iostream&gt;#include&lt;vector&gt; using namespace std; void SortVector(vector&l...