Box Functions, C++ using QTCreator: I need the functions in c++, not. picture of some piece of paper, I need actual help

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Box Functions, C++ using QTCreator: I need the functions in c++, not. picture of some piece of paper, I need actual help

Post by answerhappygod »

Box Functions, C++ using QTCreator:
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 1
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 1 (62.31 KiB) Viewed 66 times
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 2
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 2 (65.73 KiB) Viewed 66 times
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 3
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 3 (97.07 KiB) Viewed 66 times
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 4
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 4 (111.61 KiB) Viewed 66 times
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 5
Box Functions C Using Qtcreator I Need The Functions In C Not Picture Of Some Piece Of Paper I Need Actual Help 5 (66.16 KiB) Viewed 66 times
I need the functions in c++, not. picture of some piece of
paper, I need actual help on this, not some insult please, thank
you
Objective Upon completion of this assignment the student will be able to write functions and use unit tests to verify their functionality. Background You will be functions to help calculates information about the boxes that can be made from a sheet of cardboard. Say we have a sheet of cardboard that has a width of y and a length of z. We can make cuts of size x as shown below in the leftmost picture, then fold the sides up to make a box with the dimensions y - 2x by z - 2.c by 2. z - 2x Z - 2x 2x у y - 2x

Assignment Instructions Make a UnitTest project in QTCreator, rename sample Tester.cpp to boxFunctions.cpp and replace it with the starter code from this copy of boxFunctions.cpp. If a given TEST_CASE fails to compile, or crashes while running, comment it back out before submission so I can see the rest of the tests run. Leave in your code that you tried to write for the test, you can still get partial credit for untested code. If a TEST_CASE does compile and run, but fails, leave it uncommented. A failed test is better than a commented out one - it represents working code that clearly identifies a problem that could be worked on more. In terms of scoring for each function: Passing Test > Failing Test > Commented-Out Test > Does not Compile OR Missing See below for tips on specific functions. Submission Submit these files: • boxFunctions.cpp I should be able to compile and run your program by adding my own copy of doctest.h and doing: 9++ -std=C++11 boxFunctions.cpp -o program.exe program.exe (-/program.exe on a mac)

Functions Guide The following functions are what you need to actually implement. There is one or more unit test for each function. Each function must be preceded by a doxygen comment with a brief description of the function overall, and descriptions of its parameters and return value. It is strongly recommended you attack them by working on one unit test at a time. Uncomment the next unit test in the file and build a new function (or modify existing functions) until you pass the test. int getArea(int width, int length) For a given width and length, return area of the corresponding rectangle. int getVolume(int width, int length, int height) For a given width, length and height, return volume of corresponding box. This must use getArea as a helper for full credit. int leftoverCardboard(int cutoutSize) For a given size cutout (3), return the number of square inches of leftover cardboard (total area cut out at the corners). For example, leftoverCardboard (3) should return 36. int getMaxHeight(int width, int length) For a given width and length, returns the maximum height (whole number) that results in a valid box (all dimensions greater than 0). int getBestHeight(int width, int length) For a sheet of cardboard of the given width and length, return the height of the "best" box to make from it. The "best" box is the one that has the maximum possible volume, and if there are multiple with the same volume, the one of those with the greatest height. (It will always have more leftover cardboard, which we can recycle to make more boxes with.)

int getBestHeight(int width, int length) For a sheet of cardboard of the given width and length, return the height of the "best" box to make from it. The "best" box is the one that has the maximum possible volume, and if there are multiple with the same volume, the one of those with the greatest height. (It will always have more leftover cardboard, which we can recycle to make more boxes with.) For example the possible boxes given a 16 x 14 sheet are shown below. The "best" box has a height of 3. It is tied for the most volume with height 2, but results in more leftover cardboard, Leftover Amount Height 1 2 Width 14 12 18 Length 12 10 8 3 Volume 168 240 240 192 120 48 4 16 36 64 100 144 6 5 6 4 2 4 Hint: Notice that as the height increases, volume will increase as well until it reaches a point at which it starts decreasing. The last height that does not produce a smaller volume is the best one. In the fable above, height 1 produces a volume of 168; height 2 produces a volume of 240, which is not smaller than the 168 we saw; height 3 produces a volume of 240, which is again not smaller than the value of 240 we saw with height 2; height 4 produces a volume of 192, which is smaller than the 240 we saw at the last step. Therefore, the best height is 3 - there is no need to even consider the other possible heights. For full credit, you must use your other functions and not duplicate their logic. Only worry about integer heights. You do not have to worry about length or width being less than 3. string createBoxStatsString(int w, int , int h) Return a string that for a box of the given dimensions, builds a string containing the following information: Height Width Length Volume Leftover Amount The information should be formatted so that it is left justified in columns of width 8, except for the last value (Leftover Amount), which should just be added without any specific width

To do this well, you will want to use left and setw(size) and not tabs or space characters. To use those, you have to build up your string in a stringstream: stringstream outStream; outStream << left << setw(8) « data; outStream < ... string result = outStream.str(); If you are having problems seeing your spacing while debugging, try doing outStream << setfill('.') before building your output. void printBoxOptions(int width, int length) For a sheet of cardboard of the given width and length, print out a table like the one below of the possible boxes. Next to the best box (as defined in getBestHeight), print For a sheet that is 20 x 15, you should print something like: Height Width 1 2 3 4 5 6 7 6 ******** Length Volume Leftover Amount 13 234 4 11 352 16 9 378 36*** 7 336 64 5 100 3 144 144 1 196 again The columns of output should be cleanly lined up with the headers. For full credit, you must use your other functions and not duplicate their logic.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply