# CMPSC 201  Programming Project 3

Original price was: \$35.00.Current price is: \$30.00.

Category:
Rate this product

CMPSC 201
Programming Project 3
Worth 50 points
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. For example, the
message may be something like
“The height of the sample must be greater than zero.
Please re-enter the height of the sample.”
or
“The radius of the bubbles must be greater than zero.
Please re-enter the radius of the bubbles.”
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 void 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
Programming Project 3 2 CMPSC 201 – Spring 2016
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). For example you error message should be something like
“The number of spherical bubbles must be greater than or equal to 0.
Please re-enter the number of spherical bubbles.”
 A value-returning function will accept the radius of a sphere then calculate and return
the volume of a sphere (vol = 4/3r
3
).
 A value-returning function that will accept the radius and height of a cylinder, then
calculate and return the volume of a cylinder (vol = r
2h).
 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 smple, 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.
Make sure you use appropriate data types and that your submission follows the assignment
guidelines posted on ANGEL. The value of pi should be declared as a constant of 3.14159.
Three example outputs are given below.
Please remember to follow the assignment guidelines for the course (posted on ANGEL. For
example, 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.
Programming Project 3 3 CMPSC 201 – Spring 2016
Example 1: (user’s input is shown in bold)
Enter the height, length, and width of the sample in centimeters. 25.8 40.67 35.5
How many spherical bubbles are present? 10
What is the radius of the spherical bubbles in centimeters? 1.2
How many cylindrical pores are present? 8
What are the radius and height of the cylindrical pores in centimeters? 0.8 4
The material contains 0.337 % air.
Example 2: (user’s input is shown in bold)
Enter the height, length, and width of the sample in centimeters. -3 28 56.5
The height of the sample must be greater than zero.
Please re-enter the height of the sample. -4.5
The height of the sample must be greater than zero.
Please re-enter the height of the sample. 25
How many spherical bubbles are present? -50
The number of spherical bubbles must be greater than or equal to 0.
Please re-enter the number of spherical bubbles. 50
What is the radius of the spherical bubbles in centimeters? 0.9
How many cylindrical pores are present? 20
What are the radius and height of the cylindrical pores in centimeters? 1 -2.5
The height of the cylindrical pores must be greater than 0.
Please re-enter the height of the cylindrical pores. 1.5
The material contains 0.624 % air.
Programming Project 3 4 CMPSC 201 – Spring 2016
Example 3: (user’s input is shown in bold)
Enter the height, length, and width of the sample in centimeters. -3 -5 -10
The height of the sample must be greater than zero.
Please re-enter the height of the sample. -4.5
The height of the sample must be greater than zero.
Please re-enter the height of the sample. 10
The length of the sample must be greater than zero.
Please re-enter the length of the sample. -7.8
The length of the sample must be greater than zero.
Please re-enter the length of the sample. -71
The length of the sample must be greater than zero.
Please re-enter the length of the sample. 20
The width of the sample must be greater than zero.
Please re-enter the width of the sample. -1
The width of the sample must be greater than zero.
Please re-enter the width of the sample. -15
The width of the sample must be greater than zero.
Please re-enter the width of the sample. -4
The width of the sample must be greater than zero.
Please re-enter the width of the sample. 30
How many spherical bubbles are present? -5
The number of spherical bubbles must be greater than or equal to 0.
Please re-enter the number of spherical bubbles. -7
The number of spherical bubbles must be greater than or equal to 0.
Please re-enter the number of spherical bubbles. 40
What is the radius of the spherical bubbles in centimeters? -2.3
The radius of the bubbles must be greater than zero.
Please re-enter the radius of the bubbles. 0.5
How many cylindrical pores are present? -1
The number of cylindrical pores must be greater than or equal to 0.
Please re-enter the number of cylindrical pores. -7
The number of cylindrical pores must be greater than or equal to 0.
Please re-enter the number of cylindrical pores. 20
What are the radius and height of the cylindrical pores in centimeters? -1 -2.5
The radius of the cylindrical pores must be greater than 0.
Please re-enter the radius of the cylindrical pores. 0.8
Programming Project 3 5 CMPSC 201 – Spring 2016
The height of the cylindrical pores must be greater than 0.
Please re-enter the height of the cylindrical pores. 1.5
The material contains 1.35 % air.

## Reviews

There are no reviews yet.

Scroll to Top