Design, write, compile, and run a C++ program that calculates and displays the v
ID: 3573966 • Letter: D
Question
Design, write, compile, and run a C++ program that calculates and displays the velocity of water flowing out of the tube shown in Figure 2.19. The velocity of water flowing into the tube is I ft/sec, the input tube radius is 0.75 in. and the output tube radius is 0.5 in. The output velocity is given by this formula: v_out = v_in (r_in/r_out)^2 v_out is the output velocity. V_in is the input velocity. r_out is the radius of the output tube. R_in is the radius of the input tube. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the output velocity for a tube having an input radius of 1 in and an output radius of .75 in. when water is flowing into the tube at a rate of 1.5 ft/see.Explanation / Answer
Code:
#include<iostream>
#include<cmath>
using namespace std;
class Velocity
{
double rin,rout,vin,vout;
public:
Velocity(double ri,double ro,double vi)
{
rin=ri;rout=ro;vin=vi;
}
void assignValues(double ri,double ro,double vi)
{
rin=ri;rout=ro;vin=vi;
}
void calculateVout(void)
{
double d=rin/rout;
double sq=pow(d,2);
vout=vin * sq;
cout<<"The output velocity for the water flowing out of the tube having rin="<<rin<<",rout="<<rout<<",vin="<<vin<<" is:"<<endl;
cout<<"Vout="<<vout<<endl;
}
};
int main(void)
{
Velocity v(0.75,0.5,1);
v.calculateVout();
double ri,ro,vi;
cout<<"Enter rin,rout and vin respectively:"<<endl;
cin>>ri>>ro>>vi;
v.assignValues(ri,ro,vi);
v.calculateVout();
return 0;
}
Output:
The output velocity for the water flowing out of the tube having rin=0.75,rout=0.5,vin=1 is:
Vout=2.25
Enter rin,rout and vin respectively:
1 0.75 1.5
The output velocity for the water flowing out of the tube having rin=1,rout=0.75,vin=1.5 is:
Vout=2.66667
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.