Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ In Labs 1-3 Makeup, you were required to write 6 while loops to check input for dimensions of 3-dimensional objects. For this lab, you

c++

In Labs 1-3 Makeup, you were required to write 6 while loops to check input for dimensions of 3-dimensional objects. For this lab, you should redo Labs 1-3 makeup with function calls replacing the while loops to check dimensions and write a function to check the validity. (I have posted a possible solution for Labs 1-3 makeup that you can use if you did not do Labs 1-3 makeup. Review this possible solution, fix any errors, then make the changes for this lab.) The new function that you add to check the validity should accept two parameters: one a double and one a string. You should send the dimension that is being checked to the double parameter and a description of what that dimension stands for (e.g. radius of sphere, height of box, etc.) to the string parameter. The function should employ a single while loop to check the validity of dimension and prompt the user to re-enter the dimension when it is wrong. There should not be any selection structures in this function. Your error message should what dimension is wrong be similar to The length of the box cannot be less than zero. Please enter the length of the box again. You should only have one function other than main. Do not use and string objects to store the descriptions of the dimensions, rather send a literal constant to the function.

(lab 1-3 make up) Write a program to calculate the volume of a sphere, cylinder, or box (a parallelepiped with right angles). The user should enter an s or S for a sphere, a c or C for a cylinder, or a b or B for a box. Use a while loop to confirm that the user entered a correct letter. Depending on the users input for shape the user should be prompted for the appropriate dimensions using a switch structure. Validate input for dimensions using a while loop for each entered dimension. Make sure that your while loop to check dimensions outputs what dimension is incorrect (see below for an example message). The while loops to check dimensions should be inside the branches of the switch. None of the while loops should contain selection structures. Then calculate the volume. The length of the box cannot be less than zero. Please enter the length of the box again. Your program should output the shape the user entered, the dimensions he/she entered as well as the calculated volume

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago