Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are to write a program to compute the volume of various figures. Make sure you read the directions and look at the output first.
You are to write a program to compute the volume of various figures. Make sure you read the directions and look at the output first.
double value; value = getValidInput ("Enter the height: "); cout << "Number entered was " << value;
When you run that in main, it should give the following output: (You can see this on the output, too)
Enter the height: -5.2 Number must be positive!!! Try Again Enter the height: -12 Number must be positive!!! Try Again Enter the height: 0 Number must be positive!!! Try Again Enter the height: 3.5 Number entered was 3.5
- main - This function calls the function to put the menu on the screen and get an input from the user. It then has a switch statementthat calls the appropriate function to compute the appropriate volume. Main will loop until the user types in the option to exit (which should be added to the menu). Main should only have one or two variables declared in it.
- displayMenuGetUserInput -This function displays the menu to the screen and asks the user to enter their selection. It returns the users selection. This function does not have a switch statement or loop in it. This method returns the value that the user selects, even if it is invalid.
- The following 5 functions are called from the switch statement in main. They are each responsible for getting their appropriate inputs from the user (by calling a function), calculating the volume (by calling a function), and printing it out. These functions do not return anything
- computeSphereVolume
- computeRectanglularPrismVolume
- computeConeVolume
- computeSquarePyramidVolume
- computeCylinderVolume
- getValidInput -This function gets passed a string prompt and allows the user to type in a value. It makes sure that the number that is entered is not negative and then returns the valid number. This is used to input all values needed to compute the volumes.
- The following 5 functions are called from the appropriate functions described above. The input from the user is passed into them. They compute the volume for the appropriate shape. These functions do not return anything.
- computeVolume
- computeVolume
- computeVolumeCone
- computeVolumeCylinder
- computeVolumeSquarePyramid
Output
Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: b Enter the length: 12.3 Enter the width: 7.25 Enter the height: 4.61 The volume of a rectangular prism that is 12.30 X 7.25 X 4.61 is 411.10 Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: p Invalid Selection Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: D Enter the radius: 7.25 Enter the height: 12 The volume of a cone with radius 7.25 and height 12.00 is 660.52 Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: a Enter the radius: -5 Number must be positive!!! Try Again Enter the radius: 0 Number must be positive!!! Try Again Enter the radius: -14 Number must be positive!!! Try Again Enter the radius: 3.58 The volume of a sphere with radius 3.58 is 192.19 Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: c Enter the radius: 6.5 Enter the height: 8 The volume of a cylinder with radius 6.50 and height 8.00 is 1061.86 Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: e Enter the length of the base: -5 Number must be positive!!! Try Again Enter the length of the base: 0 Number must be positive!!! Try Again Enter the length of the base: 12 Enter the height: 6.85 The volume of a square pyramid with base length 12.00 and height 6.85 is 328.80 Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: y Invalid Selection Find the Volume (all measurements are in inches) A. Sphere B. Rectangular Prism C. Cylinder D. Cone (right circular) E. Square pyramid F. Exit Pick a shape to find a volume: F
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started