I can not get the checkD() function to work properly. What am I doing wrong? /*
ID: 3738282 • Letter: I
Question
I can not get the checkD() function to work properly. What am I doing wrong?
/* Bryce Marshall
Project 3
Section: 004r
Purpose: To approximate the volume of minor phase in a new composite
material by analyzing a rectangular parallelepiped.
To determine what % of material is from cylinders
and what % of materials is bubbles. Assume that all bubbles and
cylinders are the same size.
Input: Dimensions in length, width, height.
number of cylinders
number of bubbles
radius of bubbles
height of cylinders
Output:
*/
#include<iostream>
#include<string>
using namespace std;
double checkD(double dim, string pipe);
void check_bubs_cyls(double num, string bubbles );
double V_of_S(double radius);
double V_of_C(double height, double rad_cyls);
double vol_piped(double Height, double Length, double Width);
double percent_phase_calc(double wid_piped, double leng_piped, double hei_piped, double bubs_num, double bubs_rad, double cyl_contacts, double cyli_rad, double cyli_height);
const float PI = 3.14159;
int main()
{
double L,W,H, num_bubs,radius,num_cyls, cyl_rad, cyl_h;
cout << "Enter the height, length and width of the parallelepiped in centimeters: ";
cin >> H >> L >> W;
checkD(H, "Height of parallelepiped");
checkD(L, "Length of parallelepiped");
checkD(W, "Width of parallelepiped");
cout << "How many spherical bubbles are present in the material? ";
cin >> num_bubs;
check_bubs_cyls(num_bubs, "Number of spherical bubbles");
cout << "What is the radius of the spherical bubbles: ";
cin >> radius;
check_bubs_cyls(radius, "Bubble Radius");
cout << "Enter the number of cylinders: ";
cin >> num_cyls;
check_bubs_cyls(num_cyls, "Number of Cylinders");
cout << "What is the height and radius of the cylinder? ";
cin >> cyl_h >> cyl_rad;
check_bubs_cyls(cyl_h, "Height of Cylinders");
check_bubs_cyls(cyl_rad, "Radius of Cylinders");
percent_phase_calc(W,L,H,num_bubs, radius, num_cyls, cyl_rad, cyl_h);
return 0;
}
double checkD(double D, string P)
{
while(D < 0);
{
cout << "The " << P << " must be greater than zero"
" Please re-enter a positive value: " << endl;
cin >> D;
}
return D;
}
void check_bubs_cyls(double numb, string B)
{
while(numb <= 0);
{
cout << "Number of bubbles must be greater than or equal "
"to zero. Please re-enter a positive value for the "
<< B << " ." << endl;
}
}
double V_of_S(double sphere_rad)
{
int V;
V = (4.0/3.0)*PI*(sphere_rad*sphere_rad*sphere_rad);
return V;
}
double V_of_C(double how_high, double rad_cylinder)
{
int Vol;
Vol = 2.0*(rad_cylinder*rad_cylinder)*how_high;
return Vol;
}
double vol_piped(double HT, double Lth, double Wth)
{
int volume;
volume = HT*Lth*Wth;
return volume;
}
double percent_phase_calc(double piped_W, double piped_L, double piped_H, double bubble_num, double bubble_rad, double num_of_cyls, double the_cyl_rad, double the_cyl_height)
{
double perc_sec_phase;
V_of_C(the_cyl_height, the_cyl_rad);
V_of_S(bubble_rad);
vol_piped(piped_W, piped_L, piped_H);
cout << V_of_C;
cout << V_of_S;
cout << vol_piped;
return perc_sec_phase;
}
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
double checkD(double dim, string pipe);
void check_bubs_cyls(double num, string bubbles );
double V_of_S(double radius);
double V_of_C(double height, double rad_cyls);
double vol_piped(double Height, double Length, double Width);
double percent_phase_calc(double wid_piped, double leng_piped, double hei_piped, double bubs_num, double bubs_rad, double cyl_contacts, double cyli_rad, double cyli_height);
const float PI = 3.14159;
int main()
{
double L,W,H, num_bubs,radius,num_cyls, cyl_rad, cyl_h;
cout << "Enter the height, length and width of the parallelepiped in centimeters: ";
cin >> H >> L >> W;
checkD(H, "Height of parallelepiped");
checkD(L, "Length of parallelepiped");
checkD(W, "Width of parallelepiped");
cout << "How many spherical bubbles are present in the material? ";
cin >> num_bubs;
check_bubs_cyls(num_bubs, "Number of spherical bubbles");
cout << "What is the radius of the spherical bubbles: ";
cin >> radius;
check_bubs_cyls(radius, "Bubble Radius");
cout << "Enter the number of cylinders: ";
cin >> num_cyls;
check_bubs_cyls(num_cyls, "Number of Cylinders");
cout << "What is the height and radius of the cylinder? ";
cin >> cyl_h >> cyl_rad;
check_bubs_cyls(cyl_h, "Height of Cylinders");
check_bubs_cyls(cyl_rad, "Radius of Cylinders");
percent_phase_calc(W,L,H,num_bubs, radius, num_cyls, cyl_rad, cyl_h);
return 0;
}
double checkD(double D, string P)
{
while(D < 0)
{
cout << "The " << P << " must be greater than zero"
" Please re-enter a positive value: " << endl;
cin >> D;
}
return D;
}
void check_bubs_cyls(double numb, string B)
{
while(numb <= 0);
{
cout << "Number of bubbles must be greater than or equal "
"to zero. Please re-enter a positive value for the "
<< B << " ." << endl;
}
}
double V_of_S(double sphere_rad)
{
int V;
V = (4.0/3.0)*PI*(sphere_rad*sphere_rad*sphere_rad);
return V;
}
double V_of_C(double how_high, double rad_cylinder)
{
int Vol;
Vol = 2.0*(rad_cylinder*rad_cylinder)*how_high;
return Vol;
}
double vol_piped(double HT, double Lth, double Wth)
{
int volume;
volume = HT*Lth*Wth;
return volume;
}
double percent_phase_calc(double piped_W, double piped_L, double piped_H, double bubble_num, double bubble_rad, double num_of_cyls, double the_cyl_rad, double the_cyl_height)
{
double perc_sec_phase;
V_of_C(the_cyl_height, the_cyl_rad);
V_of_S(bubble_rad);
vol_piped(piped_W, piped_L, piped_H);
cout << V_of_C;
cout << V_of_S;
cout << vol_piped;
return perc_sec_phase;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.