Write a C++ console application that will be used to determine if rectangular packages can fit inside one of a set of spheres. Your program will pro
Use your first and last initials to name the two files you need to submit.
For example, when William J. Groen submits his work, the name of the file containing source code will be named "WGLab4.zip" and the name of the file containing screen shot for the execution of the program should be WGLab4.docx.
Name Samir Khatri
Lab 4
Write a C++ console application that will be used to determine if rectangular packages can fit inside one of a set of spheres. Your program will prompt the user for the three dimensions that define a rectangular box; the length, the width, and the height. The interior diameter of a sphere is used to identify its size. Spheres are available in the following five sizes: 5-inch, 7-inch, 9-inch, 11-inch, and 13-inch. Your program will execute repeatedly until the user enters a value of zero for one or more of the rectangular box dimensions. After obtaining the dimensions of the rectangular box, your program will call a function named calculateSphere that determines if the box will fit inside one of the five spheres.
The formula for calculating the diagonal of a rectangular box is:
Where = diagonal L = length
W = width
H = height
All the dimensions are in inches.
For example, a rectangular box that is 3 inches long by 4 inches wide and is 5 inches in height has a diagonal dimension that is calculated as follows:
In this example, the diagonal is 7.07107 inches. A 7-inch sphere would not work. However, an 9-inch sphere could accommodate the box. Some of the dimensions of the boxes will be expressed as floating-point numbers, such as 4.5 or 3.75.
The main program will keep track of how many of each of the five sizes of spheres will be needed. That is, how many 4-inch, 6-inch, 8-inch, 10-inch, and 12-inch spheres will be needed.
Your program will use a function named calculateSphere to determine if a rectangular box can fit inside one of the spheres. The function will receive as arguments the three dimensions of the box. If the box is too big to fit inside any of the spheres, the calculateSphere function will return the value zero (0) to your main program. Otherwise, the function should return the size of the sphere that can hold the box; either 5, 7, 9, 11, or 13. The main program will report to the user which size sphere will work or if none will work for each of the rectangular boxes. When the program terminates it will report how many of each size spheres will be needed.
Here is a sample output.
Please enter the length of the box:3.2
Please enter the width of the box:5.6
Please enter the height of the box:6.1
The diameter is: 9
This will fit in sphere of diameter 9
Do you want to calculate more sphere sizes? if so enter Y else enter N: Y
Please enter the length of the box:10
Please enter the width of the box:2
Please enter the height of the box:3
The diameter is: 11
This will fit in sphere of diameter 11
Do you want to calculate more sphere sizes? if so enter Y else enter N: Y
Please enter the length of the box:2.3
Please enter the width of the box:3.4
Please enter the height of the box:7.6
The diameter is: 9
This will fit in sphere of diameter 9
Do you want to calculate more sphere sizes? if so enter Y else enter N: N
Here is summary of the sphere needed
of Diameter 5: 0
of Diameter 7: 0
of Diameter 9: 2
of Diameter 11: 1
of Diameter 13: 0
does not fit: 0
Program Terminated
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
