C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 5PP

(Hydraulics) a. 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 1 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 o u t = v i n ( r i n r o u t ) 2

v o u t   i s   t h e   o u t p u t   v e l o c i t y . v i n   i s   t h e   i n p u t   v e l o c i t y . r o u t   i s   t h e   r a d i u s   o f   t h e   o u t p u t   t u b e . r i n   i s   t h e   r a d i u s   o f   t h e   i n p u t   t u b e .

Chapter 2, Problem 5PP, (Hydraulics) a. Design, write, compile, and run a C++ program that calculates and displays the

b. 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/sec.

(a)

Expert Solution
Check Mark
Program Plan Intro

Program plan:

In the coding window, write the necessary code:

  • ToDeclarefourdouble variablevin=1 ft/sec,rin=0.75, rout=0.5andvout.
  • To calculatethe velocity of water flowing out of the tube.
  • To displaythe calculatedvelocity of water flowing out of the tube.

Program description:

The main purpose of the program is to calculate thevelocity of water flowing out of the tubeby using the given velocity of water flowing inside the tube, input radius and output radius.In the main method,calculatingthe output velocity of water flowing out of the tube with the giveninput velocity of water flowing inside the pipe, input radius and output radius and finally,displayingthe output of velocity of water flowing out of the tubeto user.

Explanation of Solution

Giveninformation:

  vout=vin( r in r out )2

  outputvelocity,voutinputvelocity,vin=1ft/secinputradius,rin=0.75inoutputradius,rout=0.5in

Program:

Program code to calculate the velocity of water flowing out of the tube:

//importing essential header files
#include<iostream>
#include<cmath>
//using namespace standards
usingnamespace std;
//main method
int main() 
{
//declaring variable
double vin=1, rout=0.5, rin=0.75; 
double vout;
//calculating d by dividing rin by rout 
double d=rin/rout;
//now calculating the square of the d
double sq=pow(d,2);
//multiplying the above calculated value of sq with vin 
  vout=vin * sq;
//displaying output to user
  cout<<"The output velocity for the water flowing out of the tube having rin="<<rin<<",rout="<<rout<<",vin="<<vin<<" is, "<<"Vout="<<vout<<"ft/sec"<<endl;
}//end of main 

Explanation:

In the main method,four double variablevin=1 ft/sec,rin=0.75, rout=0.5andvout are declared. After that the velocity of water flowing out of the tubeis calculated by using the below given formula:

  vout=vin( r in r out )2

And the finally, calculatedresults are displayed to user.

Output:

Output of the above given program code:

  C++ for Engineers and Scientists, Chapter 2, Problem 5PP , additional homework tip  1

(b)

Expert Solution
Check Mark
Program Plan Intro

Program plan:

To verify the results produced by above program and then using the above program to the program is to calculate the outputvelocity of water flowing out of the tube with the given input velocity, vin= 1.5 ft/sec, input radius, rin=1 in and output radius, rout=0.75 in.

Explanation of Solution

Giveninformation:

  vout=vin( r in r out )2

  outputvelocity,voutinputvelocity,vin=1ft/secinputradius,rin=0.75inoutputradius,rout=0.5in

Program:

Explanation:

Firstly, verifying the results calculate by the above program.

  vout=vin( r in r out )2

  inputvelocity,vin=1ft/secinputradius,rin=0.75inoutputradius,rout=0.5in

Putting the given values in the above formula,

  vout=vin( r in r out )2vout=1ft/sec( 0.75in 0.5in)2vout=1ft/sec( 0.5625 in 2 0.25 in 2 )vout=2.25ft/sec

Thus, the calculated results are correct.

Now, modifying theprogramcodeto calculate the output velocity with the given input velocity, vin = 1.5 ft/sec, input radius, rin=1 in and output radius, rout=0.75 in.

Program code:

//importing essential header files
#include<iostream>
#include<cmath>
//using namespace standards
usingnamespace std;
//mian method
int main() 
{
//declaring variable
double vin=1.5, rout=0.75, rin=1; 
double vout;
//calculating d by dividing rin by rout 
double d=rin/rout;
//now calculating the square of the d
double sq=pow(d,2);
//multiplying the above calculated value of sq with vin 
  vout=vin * sq;
//displaying output to user
  cout<<"The output velocity for the water flowing out of the tube having rin="<<rin<<",rout="<<rout<<",vin="<<vin<<" is, "<<"Vout="<<vout<<"ft/sec"<<endl;
}//end of main 

Explanation:

In the main method,four double variablevin=1.5 ft/sec,rin=1 inch, rout=0.75inch andvout are declared. After that the velocity of water flowing out of the tube is calculated by using the below given formula:

  vout=vin( r in r out )2

And the finally, calculatedresults are displayed to user.

Output:

  C++ for Engineers and Scientists, Chapter 2, Problem 5PP , additional homework tip  2

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
(C++ CODE) A new video store in your neighborhood is about to open. However, it doesnot have a program to keep track of its videos and customers. The storemanagers want someone to write a program for their system so that thevideo store can operate.The program will require you to design 2 ADTs as described below: (C++)
(Apartment problem) A real estate office handles, say, 50 apartment units. When the rent is, say, $600 per month, all the units are occupied. However, for each, say, $40 increase in rent, one unit becomes vacant. Moreover, each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit? Write a program in C++ that prompts the user to enter: The total number of units. The rent to occupy all the units. Amount to maintain a rented unit. The increase in rent that results in a vacant unit. The program then outputs: The number of units to be rented to maximize the profit The maximum profit Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.
(C++ OOP) We have a house with 3 rooms.We need the user to enter 1 integer as the window number, 2 doubles as depth and width of the room, 1 double as the useless area, 1 boolean as the door's opening direction (e.g. 0 is outward).Program will compute and print the air condition as a string and the total useful area of the house as a double. Calculating the air condition: Name it air_c. Divide the useful area by the window number. If air_c >20, output "bad". If air_c <11 output "good". If 11<=air_c<=20, output "ideal". Attention: If the window number is 0, air condition is bad. Calculating the useful area of room: Width*Depth-(useless area)if the door is inward;Width*Depth-(useless area)-0.8The worst air condition of the 3 is the final air condition of house. --- 1)The information about the home must be all private within a class.2)The class must get these inputs within constructor func.3)Calculating the useful area of a room must be done within a function of a class.4)Air…

Chapter 2 Solutions

C++ for Engineers and Scientists

Ch. 2.1 - (Practice) You’re a sophomore in college and are...Ch. 2.1 - (Practice) You’re given the job of planting a...Ch. 2.1 - (Practice) You’re responsible for planning and...Ch. 2.1 - (Data processing) a. A national medical testing...Ch. 2.2 - (Debug) a. Will the following program work?...Ch. 2.2 - (Modify) Rewrite the following programs to conform...Ch. 2.2 - (For thought) a. When used in a message, the...Ch. 2.2 - (For thought) a. A token of a computer language is...Ch. 2.3 - (Practice) Determine data types appropriate for...Ch. 2.3 - (Practice) Compile and run Program 2.5.Ch. 2.3 - Prob. 3ECh. 2.3 - (Practice) Show how the name KINGSLEY is stored in...Ch. 2.3 - Prob. 5ECh. 2.3 - Prob. 6ECh. 2.3 - Prob. 7ECh. 2.3 - (For thought) Although you have concentrated on...Ch. 2.3 - (Practice) Although the total number of bytes...Ch. 2.4 - (Practice) For the following correct algebraic...Ch. 2.4 - (Practice) Determine the values of the following...Ch. 2.4 - (Practice) Determine the value of the following...Ch. 2.4 - (Practice) Evaluate the following mixed-mode...Ch. 2.4 - Prob. 5ECh. 2.4 - Prob. 6ECh. 2.4 - Prob. 7ECh. 2.4 - Prob. 8ECh. 2.4 - Prob. 9ECh. 2.4 - (Program) Write a C++ program that displays the...Ch. 2.4 - Prob. 11ECh. 2.5 - (Practice) State whether the following variable...Ch. 2.5 - Prob. 2ECh. 2.5 - (Practice) a. Write a declaration statement to...Ch. 2.5 - Prob. 4ECh. 2.5 - Prob. 5ECh. 2.5 - Prob. 6ECh. 2.5 - Prob. 7ECh. 2.5 - Prob. 8ECh. 2.5 - (Practice) a. Using Figure 2.14 and assuming the...Ch. 2.5 - Prob. 10ECh. 2.5 - Prob. 11ECh. 2.6 - (Modify) a. Modify Program 2.11 to calculate the...Ch. 2.6 - (Modify) a. Modify Program 2.11 to determine the...Ch. 2.6 - Prob. 3ECh. 2.6 - Prob. 4ECh. 2.6 - (Conversion) a. Design, write, compile, and run a...Ch. 2.6 - (Hydraulics) a. Write, compile, and run a C++...Ch. 2.6 - (Thermodynamics) a. Design, write, compile, and...Ch. 2.6 - Prob. 8ECh. 2 - (General math) a. Design, write, compile, and run...Ch. 2 - (General math) a. Design, write, compile, and run...Ch. 2 - (Physics) a. Design, write, compile, and run a C++...Ch. 2 - Prob. 4PPCh. 2 - (Hydraulics) a. Design, write, compile, and run a...Ch. 2 - Prob. 6PPCh. 2 - (Physics) a. The weight of an object on Earth is a...Ch. 2 - (Modify) a. Modify the program you wrote for...Ch. 2 - (Civil eng.) The maximum load that can be placed...Ch. 2 - (Civil eng.) Modify the program written for...Ch. 2 - (Mechanical eng.) The minimum radius required for...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License