(Hydraulics) a. Design, write, compile, and run a C++
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)
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:
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:
And the finally, calculatedresults are displayed to user.
Output:
Output of the above given program code:
(b)
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:
Program:
Explanation:
Firstly, verifying the results calculate by the above program.
Putting the given values in the above formula,
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:
And the finally, calculatedresults are displayed to user.
Output:
Want to see more full solutions like this?
Chapter 2 Solutions
C++ for Engineers and Scientists
- (USING C++)A new video store in your neighborhood is about to open. However, it does not have a program to keep trackof its videos and customers. The store managers want someone to write a program for their system so thatthe video store can operate.arrow_forward(c++) Write a program that takes user input describing a playing card with the following shorthand: A = Ace 2...10 card values J = Jack Q = Queen, etc. D = Diamonds S = Spades. etc. Ex. if the user enters QS then your program responds with Queen of Spadesarrow_forward(C++) Write a function definition called quotient that takes as its parameters two decimal values, numer and denom, to divide. Remember that division by 0 is not allowed. If division by 0 occurs, display the message "NaN" to the console, otherwise display the result of the division and its remainder.arrow_forward
- 12. (Data processing) Write, run, and verify a C++ program that accepts three numbers as input, and then sorts the three numbers and displays them in ascending order, from lowest to highest. For example, if the input values are 7 5 1, the program should display them in the numerical macorder 1 5 7.arrow_forward(C++ Programming language) There are following two major issues associated with cpp programs:• When a program is terminated, the entire data is lost. • If you have to enter a large number of data, it will take a lot of time to enter them all in the different programs.Suggest a solution and elaborate the same with the help of suitable examples.arrow_forward(C PROGRAMMING ONLY) 1. Dealing With Monthsby CodeChum Admin We're done dealing with days. It's time to step up and now deal with months! Instructions: In the code editor, you are provided with a code in the main() which has 12 printf's. Each printf prints a month with its corresponding value. For this program, January is 1, February is 2, March is 3, and so on. When you run the initial code, you will encounter errors because these month names that have been printed don't exist yet.Your task is to create an enum data type which contains these month names as values so that when we run the code, there will be no more error.Do not edit anything in the main(). Output January = 1February = 2March = 3April = 4May = 5June = 6July = 7August = 8September = 9October = 10November = 11December = 12arrow_forward
- ( C++ ) Write a program in C++ to print the college name, location and area code (Higher College of Technology – Al Khuwair – 33) using symbolic constants COLLEGE, AREA, CODEarrow_forward(Mathematical functions) a model of worldwide population, in billions of people, is given by this formula. Population = 6.0e0.02t Where t is the time in years (t=0 represents january 2000 and t = 1 represents january 2001). Using this formula, write a c++ program that displays a yearly population table for the years january 2005 through January 2010.arrow_forwardProblem 2. (Playing the Waltz) Write a program called playwaltz.py that accepts from standard input, a sequence of 32 integers representing the 32 measures of a waltz, and plays the waltz to standard audio. Before playing any audio, your program must check if the inputs are correct, and if they are not, must call sys.exit (message) to exit the program with an appropriate error message. The following errors must be handled: • If the number of measures is not 32, exit with the message "A waltz must contain exactly 32 measures". • If a minuet measure is not from [1,176], exit with the message "A minuet measure must be from [1, 176]". • If a trio measure is not from [1,96], exit with the message "A trio measure must be from [1, 96]". - "/vorkspace/project3 $ python3 generatewaltz.py < data/mozart.txt | python3 playwaltz. py Directions: • Read the waltz measures from standard input into a 1D list. • Handle the input errors described above. • Play each of the first 16 minuet measures by…arrow_forward
- (C++) 2. Request a character from the console. Use an if/else to output if the character is an uppercase letter, a lowercase letter, or neither a letter nor a number. Example 1 Output (input in bold italics) Input a character: A A is an uppercase letter. Example 2 Output (input in bold italics) Input a character: k k is a lowercase letter. Example 3 Output (input in bold italics) Input a character: 5 5 is a number Example 4 Output (input in bold italics) Input a character: # # is not a number or a letterarrow_forward(C PROGRAMMING ONLY) Make a code with the string function of strcat (with user input) THE REQUIRED OUTPUT IS INDICATED IN THE PICTURE. (THE OUTPUT SHOULD BE EXACTLY LIKE IN THE PICTURE)arrow_forward1. (Dice simulation) Java/C++ program that computes the exact probability distribution for the sum of two dice. Run experiments to validate this calculation simulating N dice throws, keeping track of the frequencies of occurrence of each value when you compute the sum of two random integers between 1 and 6. How large does N have to be before your empirical results match the exact results to three decimal places?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education