Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Exercise Please provide code in C++ only Write a C++ console application that will be used to determine if rectangular packages can fit

C++ Programming Exercise

image text in transcribed

Please provide code in C++ only

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: 4- inch, 6-inch, 8-inch, 10-inch, and 12-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 getSphereSize that determines if the box will fit inside one of the five spheres. The formula for calculating the diagonal of a rectangular box is: DE L? + 2 + H2 Where D = 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: D=132 +42 +52 D = 19+16 + 25 D= V50 In this example, the diagonal is 7.07107 inches. A 6-inch sphere would not work. However, an 8-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 getSpheresize 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 getSpheresize function will return the value zero (0) to your main program. Otherwise, the function will return the size of the sphere that can hold the box; either 4, 6, 8, 10, or 12. 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions