Your fifth assignment is based on Programming Exercise No. 29 from pp. 464-465 of the textbook. We supply it below with

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

Your fifth assignment is based on Programming Exercise No. 29 from pp. 464-465 of the textbook. We supply it below with

Post by answerhappygod »

Your Fifth Assignment Is Based On Programming Exercise No 29 From Pp 464 465 Of The Textbook We Supply It Below With 1
Your Fifth Assignment Is Based On Programming Exercise No 29 From Pp 464 465 Of The Textbook We Supply It Below With 1 (476.58 KiB) Viewed 17 times
Your Fifth Assignment Is Based On Programming Exercise No 29 From Pp 464 465 Of The Textbook We Supply It Below With 2
Your Fifth Assignment Is Based On Programming Exercise No 29 From Pp 464 465 Of The Textbook We Supply It Below With 2 (386.5 KiB) Viewed 17 times
Your Fifth Assignment Is Based On Programming Exercise No 29 From Pp 464 465 Of The Textbook We Supply It Below With 3
Your Fifth Assignment Is Based On Programming Exercise No 29 From Pp 464 465 Of The Textbook We Supply It Below With 3 (185.28 KiB) Viewed 17 times
Please write in C++. When given the length and width write aprogram that outputs maximum volume and optimal x
Your fifth assignment is based on Programming Exercise No. 29 from pp. 464-465 of the textbook. We supply it below with important modifications (we correct errors that we suspect were not caught by the editors). Programming Exercise No. 29 29. (The box problem) You have been given a flat cardboard of area, say, 70 square inches to make an open box by cutting a square from each corner and folding the sides (see Figure 6-17). Your objective is to determine the dimensions, that is, the length and width, and the side of the square to be cut from the corners so that the resulting box is of maximum volume. FIGURE 6-17 Cardboard box length and width Write a program that prompts the user to enter the area of the flat cardboard. The program then outputs the length and width of the cardboard and the length of the side of the square to be cut from the corner so that the resulting box is of maximum volume. Calculate your answer to three decimal places. Your program must contain a function that takes as input the length and width of the cardboard and returns the side of the square that should be cut to maximize the volume. The function also returns the maximum volume. As in previous homeworks, we present the elements of the exercise in the style of the Programming Examples found in the textbook. Input The length and the width of the flat cardboard. [The problem where the input is just the area of the flat cardboard is still a valid one but the more realistic one is where the flat cardboard is already pre-cut to a specified rectangular shape. Also, the problem where only the area is the input is a bit more difficult to solve.]
The length of the side of the square to be removed from each of the four corners of the flat cardboard so that the resulting folded box is of maximum volume, and the volume of this maximal box. This problem seeks the solution by calling a function optimalside that takes in the length and the width of the flat cardboard and then returns the length of the side of the square to be cut from the four corners so that the resulting box has maximum volume. Once function optimalside is available, the algorithm becomes straightforward: 1. Prompt the user and obtain the length and width of the flat cardboard. 2. Call the function optimalside to obtain the length of the sides of the square to be removed from each of the four corners of the flat cardboard that maximizes the volume of the resulting box. 3. Display the input length and width, the length of the sides of the removed square, and the volume of the resulting maximal box. You will need variables to store the input value. You will also need variables to store the calculated values. The program needs at least the following variables: double length; //length of flat cardboard (input) double width; //width of flat cardboard (input)  double side;  double volume; ​ //side of removed square (working)  //volume of maximal box (working) ​ You will need a function that takes in as parameters the length and the width of the flat cardboard and returns the side of the square to be removed so that the resulting box is of maximum volume. Here is the function's header: double optimalside(double length, double width); Let l be the length of the flat rectangular cardboard and let w be its width. If x is the side of the square to be removed from each of the four corners, the length y and width z of the resulting box will be: y=l−2xz=w−2x​ The height of the resulting box will, of course, be x. The volume v of the resulting box will be the product of these three dimensions: v=xyzv=x(l−2x)(w−2x)v=4x3−2(l+w)x2+lwx​ Since l and w are input values, the volume v is a function of just one unknown, that is x. Taking the first derivative of this function with respect to x, we get: dv/dx=12x2−4(l+w)x+lw Setting this to zero, we can solve for x using the quadratic formula: 12x2−4(l+w)x+lw=0
x=61​(−l2−lw+w2​+l+w) and x=61​(l2−lw+w2​+l+w) Further analysis shows that the maximum is achieved when the first root is chosen. This should be the value returned by the function optimalside. Sample Run This "sample run" gives a good idea of the desired program: Enter length of rectangular cardboard: 10 Enter width of rectangular cardboard: 7 Maximum volume is achieved when x is: 1.352 Maximum volume is: 42.377 Deliverables Based on the algorithm description above and the list of variables and functions that may be needed, develop a C++ program that implements the algorithm. Use onlineGDB as you did in the previous homeworks. Once you are able to successfully compile and execute the code, using the sample run above as test case, "capture" the screen and submit it in Moodle. You should run the "correct" program several times to collect data as specified in the next section. Collecting Data Run the correct program enough times to obtain results for the following input sets:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply