Question
Write in C++ Code. Goals: Developing problem-solving skills and functions Problem: You will create a program that will approximate the volume of pores in a
Write in C++ Code.
Goals: Developing problem-solving skills and functions
Problem: You will create a program that will approximate the volume of pores in a new composite material. While the material is being formed it is injected with air which creates bubble and pores to decrease the density of the composite material. However, if too many pores and bubbles are created, the material loses its strength and catastrophic failure occurs. You are to create a program that will determine what percentage of the material is due to pores (connected to the surface) and bubbles (totally enclosed within the sample). For the purposes of this analysis all bubbles will be assumed to be the same size and all the pores will be cylinders of the same size.
The sample that is being analyzed is a rectangular parallelepiped (all angles are 90 degrees, but length, width, and height may be different values). The user will be prompted to enter the dimensions of the sample (height, length, and width), the number of the bubbles, the radius of the bubbles, the number of cylindrical pores, the radius of the cylindrical pores and the height of the cylindrical pores.
Your program should include 6 functions in addition to your main function:
A void function that will robustly confirm that the dimension entered is greater than zero. This function should accept two parameters: the dimension and what the dimension corresponds to e.g. the height of the sample, the radius of spherical bubble, etc.(see examples below). This function should contain a single loop and no selection structures. If the dimension is incorrect, the user should be told what dimension is incorrect and prompt the user to re-enter the value for the dimension.
The check should be robust (i.e. the user will be given the error message and prompted to re-enter the incorrect value as long as it is invalid.
A value-returning function that will robustly confirm that the value entered for the number of spherical bubbles or cylindrical pores is greater than or equal zero. This function should accept two parameters: the value and what the value corresponds to i.e. number of spherical bubbles or number of surface cylinders. This function should contain a single loop and no selection structures. If the value is incorrect, tell the user should be told what value (number of spherical bubbles or number of cylindrical pores) is incorrect and prompt the user to re-enter the number. (You may assume that the number will be a whole number
A value-returning function will accept the radius of a sphere then calculate and return the volume of a sphere (vol = 4/3r3).
A value-returning function that will accept the radius and height of a cylinder, then calculate and return the volume of a cylinder (vol = r2h).
A value-returning function that accept the height, length, and width of a rectangular parallelepiped then calculate and return the volume of the rectangular parallelepiped (vol = hlw).
A value-returning function that will accept 8 parameters: width, length, and height of the parallelepiped sample; the number of spherical bubbles and the radius of the bubbles; plus the number of cylindrical holes in contact with a surface and the radius and height of these cylinders. This function will call the functions to calculate the volumes, then calculate the percent of the sample that is air (combination of spherical bubbles and cylindrical pores). The percentage should be returned to the function call.
Your main function should ask the user to input the dimensions of the parallelepiped sample, the number and size of the spherical bubbles, and the number and dimensions of the surface cylinders. For each of these 8 values your main function should call the functions to confirm input is valid. After this confirmation, the function to determine the percentage of air present should be called. Then the main function should output the percentage of air present. The percentage of air should be output using 3 significant digits. You may assume that the total volume of spherical bubbles and cylindrical pores will not exceed the volume of the original sample.
The value of pi should be declared as a constant of 3.14159.
Do not use global variables, do not use break statements in loops, do not use more than one return statement per function, do not put functions definitions before main, etc.
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