Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The average velocity of water in a rectangular open channel can be calculated using the following Manning's equation. where Uis the average velocity of the

image text in transcribedimage text in transcribedimage text in transcribed

The average velocity of water in a rectangular open channel can be calculated using the following Manning's equation. where Uis the average velocity of the water (m/s), S is the channel slope n is the roughness coefficient (s/m5) B is the width (m) H is the depth of the water (m) Develop a program that requests from the user characteristics of the channel and display in table form how the average velocity of the water varies with its depth in the channel. Use the following new guidelines to develop your program. . Definitions o Define a structure type CHANNEL that contains with members for the values for the open channel, that is, members name that holds a string for the name of the channel, n (roughness coefficient), slope (value of S), width (value of B), and maxDepth that holds the maximum water depth possible in the channel. o Use a symbolic constant to determine the number of lines to display in the table on the console. Use 25 lines in the table to display. Use other symbolic constants to eliminate magic numbers in your program. In the main function: o Declare a variable of type cHANNEL which will contain channel characteristics. o Declare either a two dimensional (2D) array or two one dimensional (1D) array which shal contain values of type double. In the case of the 2D array, the first row contains the water depth values and the second row contains average water velocity values. In the case of two 1D arrays, one array contains the water depth values and the other contains average water velocity values. Get from the user values to initialize all the members of the structure variable of type CHANNEL by calling the function getInput. o o Fill the 2D array (or the two 1D arrays) by calling the function fillArray. o Display on the console the desired output by calling the function displayTable. o Thus the main function contains only 3 calls to functions (in addition to declaring variables). Address of the structure variable and arrays are passed to the called functions. In the function getInput o This function has only a single parameter, a pointer to a value of type CHANNEL o Use the function fgets to initialise the member name (this function will place the complete line typed by the user including spaces as opposed to the scanf function that stops when it encounters a space). For the value of the other members of the structure variable (that are of type double), used the function getPositiveValue from the CylinderVolumeLab5 project to ensure that a positive value is stored in each of these members. Be sure to use the getPostiveValue function from lab 5 and not the version from lab 4 o This function DOES NOT return any value In the function fillArray: This function has a pointer parameter to a value of type CHANNEL. It also has the necessary parameters to fill the 2D array (or the 1D arrays) declared in the main function. The function shall fill in the array(s) with the values of depth and average velocity. It obtains the values of average velocity by calling the function computeVelocity. Note that Manning's equation cannot be applied to a depth with value 0. Thus the displayed table does not start at a depth of 0, but at the increment value used to increment the depth of the water o o In the function displayTable This function has a pointer parameter to a value of type CHANNEL. It also has the necessary parameters to fill the 2D array (or the 1D arrays) declared in the main function. The function displays on the console first the characteristics of the channel followed by a table of 25 lines that shows how the average speed of the water changes with its depth. shows an example of the desired output. Be sure to properly format the values. o o The following CurrentCourses GNG1106 Fall2018 Assi... Give the name of the channel Give the coefficient of roughness 0.035 Give the slope: 0.0001 Give the channel width 10 Give the maximum depth of the channel: 4.2 hanne Channel data for "Channel 1" Coefficient of roughness: 0.0350 Slope: 0.00010 Width: 10.00 Maximum depth 4.20 Depth_.---91o Average velocity 0.50 0.67 0.84 1.01 18 34 51 68 85 2.02 2. 18 2.35 0.5661 0.4232 0.3424 0. 2894 0.2515 0.2228 0.2002 0. 1819 0.1667 0. 1538 0.1428 0. 1333 0.1249 2.69 2.86 3.02 3.19 3.36 3.53 3.70 3.86 4.03 4.20 0. 1109 0. 1050 0.0997 0.0948 0,0904 0.0864 0.0826 0.0792 0.0760 0.0731 Process returned 0 (x0) execution time: Press any key to cont i nue Function computeVelocity This function has two parameters, one of type double which gives the depth of the water, and the second of type pointer to a value of type CHANNEL which contains the characteristics of the channel. o o It computes the average velocity of the water using Manning's equation and returns this value . The following table gives three test cases to be used for testing your program Name Chl1 Name n (s/m^1/3) 0.0013 Width (m)2 Channel 2 Name Channel 3 ess n n (sm.. 13) | 0.035 Slo Width(m Max. Depth 0.0001 0.0032 Sl Width (nm Max. Depth 40 Max. Depth In Average Velocity Average Average Velocitv Depth (m) 0.1680 0.917961 0.33600.566077 0.50400.423161 0.6720 0.342380 0.84000.289368 1.00800.251450 1.1760 0.222759 1.34400.200172 1.51200.181859 1.68000.166669 1.84800.153840 2.0160 0.142843 2.18400.133301 2.35200.124935 2.52000.117535 2.6880 0.110939 2.85600.105020 3.0240 0.099677 3.19200.094829 3.36000.090410 3.5280 0.086363 3.69600.082644 3.8640 0.079214 4.03200.076040 4.20000.073095 0.460056.740241 0.9200 29.778691 1.3800 19.693713 1.8400 14.450211 2.300011.266883 2.7600 9.146052 3.2200 7.641631 3.6800 6.524830 4.1400 5.666601 4.6000 4.988857 5.0600 4.441703 5.52003.991847 5.9800 3.616268 6.4400 3.298570 6.9000 3.026780 7.36002.791958 7.8200 2.587308 8.28002.407573 8.74002.248630 9.20002.107203 9.66001.980655 10.1200 1.866844 10.5800 1.764015 11.0400 1.670711 11.50001.585720 0.0600 7.756067 0.1200 4.876297 0.1800 3.713932 0.2400 3.059721 0.30002.631589 0.3600 2.325820 0.4200 2.094561 0.4800 1.912415 0.5400 1.764548 0.6000 1.641663 0.66001.537612 0.7200 1.448154 0.7800 1.370260 0.8400 1.301702 0.9000 1.240806 0.9600 1.186282 1.02001.137124 1.0800 1.092530 1.1400 1.051856 1.20001.014577 1.2600 0.980258 1.3200 0.948540 1.3800 0.919119 1.44000.891740 1.5000 0.866183 The answer to this question should provide in the assignment file file 1) 2) The source code to your program (also insert the source code into your assignment file) The output for each test case in the above table into your assignment file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

What is a bond rating?

Answered: 1 week ago