Question: Develop a program in C that requests from the user characteristics of the channel and display in table form how the average velocity of the

Develop a program in C 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.

The following equation is used:

Develop a program in C that requests from the user characteristics of

Guidelines:

Definitions

- Define a structure type CHANNEL that contains the 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 (s value), width (value of B), and maxDepth which holds maximum depth of channel

- use a symbolic constant to determine the number of lines to display in the table on the console. Use 25 lines in table to display. Use other symbolic constants to eliminate magic numbers

Function main:

- Declare a variable of type CHANNEL which contains channel characteristics

- Declare a two dimensional (2D) array which shall contain values of type double. First row must contain the water depth values, second row maintains average water velocity values.

- Get from user the values to initialize all the members of the structure by calling the function getInput

- Fill the 2D array by calling function fillArray

- Display on console the desired output by calling the function displayTable

Function getInput:

-single parameter: pointer to a value of type CHANNEL

-use the function gets to initialize 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 used function getPositiveValue **CODE FOUND BELOW**

Function fillArray:

- pointer parameter to a value of type CHANNEL. Also has necessary parameters to fill the 2D array declared in main

-Function shall fill array with values of depth and average velocity. Obtains average velocity values by calling the function computeVelocity which solves given equation. THIS DOESN'T WORK ON 0 so table doesnt start at 0.0 but at the increments value used to increment the depth of water.

Function displayTable

-pointer parameter to a value of type CHANNEL. Also has necessary parameters to fill the 2D array declared in main

function displays on console the first characteristics of the channel followed by the table of 25 lines that show the average velocity and how it changes relative to depth.

Function computeVelocity

-two parameters: 1) type double which gives the depth of the water 2) pointer to a value of type CHANNEL

- computes average velocity using equation and returns this value Test cases: the channel and display in table form how the average velocity of

2/3 where U is 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) 1/3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!