Please Solve in C++

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: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please Solve in C++

Post by answerhappygod »

Please Solve in C++
Please Solve In C 1
Please Solve In C 1 (362.54 KiB) Viewed 26 times
Please Solve In C 2
Please Solve In C 2 (273.95 KiB) Viewed 26 times
Please Solve In C 3
Please Solve In C 3 (171.76 KiB) Viewed 26 times
Please Solve In C 4
Please Solve In C 4 (49 KiB) Viewed 26 times
Homework No. 4 Your fourth assignment is from pp. 344-345 of the textbook. It is Programming Exercise No. 27. We supply it below. Programming Exercise No. 27 27. (The conical paper cup problem) You have been given the contract for making little conical cups that come with bottled water. These cups are to be made from a circular waxed paper of 4 inches in radius by removing a sector of length x (see Figure 5-4). By closing the remain- ing part of the circle, a conical cup is made. Your objective is to remove the sector so that the cup is of maximum volume. Input Output GP 4 h PROBLEM ANALYSIS AND ALGORITHM DESIGN r FIGURE 5-4 Conical paper cup Write a program that prompts the user to enter the radius of the cir- cular waxed paper. The program should then output the length of the removed sector so that the resulting cup is of maximum volume. Cal- culate your answer to two decimal places. 4 We present the elements of the exercise in the style of the Programming Examples found in the textbook (esp. p. 293 and p. 305). The radius of the circular waxed paper. The length of the removed sector that maximizes the resulting volume of the cone. This problem seeks the solution by repeatedly calculating the volume of the resulting cone as the length of the removed sector is incremented starting at 0 to the circumference of the circular wax paper. The value for which the volume is maximum is remembered and ultimately displayed as the output of the solution.
Variables Formulas The algorithm is straightforward: 1. Prompt the user and obtain the radius of the circular waxed paper. 2. Compute the circumference of the circular waxed paper. 3. For values of the removed sector ranging from 0.0 to the circumference, calculate the volume of the resulting cone, remembering the maximum such volume and retaining the length of the removed sector that gave the maximum (a loop is needed here!). 4. Display the length of the removed sector that maximized the volume of the resulting cone as determined in the repeated iteration of Step No. 3. 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 radius; double circumference; double circumferenceCone; double height; double volume; double x; double optimalX; double maxVolume; //radius of circular paper (input) //circumference of circular //wax paper (working) //circumference of resulting //cone (working) //height of resulting //cone (working) //volume of resulting //cone (working) //length of removed //sector (working) //best value of x (output) //maximum volume (output) Let R be the radius of the circular wax paper. The circumference c of the paper is given by the formula: c=2πR The circumference C of the mouth of the cone is given by: C=c-x where x is the length of the removed sector. From this we can calculate the radius r of the circular mouth of the cone: r = C/(2π) We can now express the heighth of the cone by noting that together with R and r we have a right triangle. 7 R
And so: h=√ R²-p² The volume v of the cone is given by the formula: v = (1/3)π r²h This is what needs to be tracked as it evolves when x is made to range from 0.01 to just below 2πR. h² +²²=R² h²=R²_p² Sample Run This "sample run" gives a good idea of the desired program: Enter radius of circular wax paper: 4 Maximum volume is achieved when x is: 4.61 Maximum volume is: 25.80 Deliverables Based on the algorithm description above and the list of variables 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: Radius 4 10 Optimal x 4.61 Maximum Volume 25.80
Collecting Data Run the correct program enough times to obtain results for the following input sets: Radius 4 10 40 0 Optimal x 4.61 Maximum Volume 25.80
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply