Please can you solve this problem in C my final exam is next friday I want to know the answer for it before the exam.My exam is at 4 p.m.
Create a software solution to support analysis of flow rate values (discharge) for

trapezoidal open channels according to following guidelines:

1. Provides the users with one of four functions: (1) create a flow rate matrix for a series

of depth values and bottom width values with given values for Manning coefficient of

roughness n, slope of water surface S, and slope of the trapezoid side z; the flow rate

table that consist of the matrix and the values of all parameters used to create the

matrix are stored in a file; (2) Load a flow rate table from an existing file (3) print the

currently loaded table; and (5) using the loaded table estimate the water depth given a

base width and flow rate. The following is an example of the initial menu presented:

1. Create a flow rate table

2. Load an existing flow rate table

3. Display currently loaded flow rate table

4. Estimate water depth using flow rate table

5. Terminate

2. The following pseudo-code describes a structure to be used to contain the information

about a selected table. Note that two structures are defined for creating members of

the flow rate table structure. Use a global structure variable for storing flow rate table

data.

Define PARAM structure that contains:

s (slope of the water, real value)

z (slope of channel side, real value)

n (coefficient of roughness, real value)

initialValue (initial value of the parameter)

stepSize (step size for the parameter

Define FLOW_RATE_TABLE structure that contains:

name (string that contains the table name)

params (a PARAM structure)

flowRates is a matrix of real values of size NUMROWS by NUMCOLS

(rows – contains q values for given depth)

(columns – contains q values for given base width)

Declare flowRateTable global structure variable as a FLOW_RATE_TABLE structure

3. The flow rate matrix is a 10 X 10 matrix (i.e. NUMROWS and NUMCOLS are both

equal to 10). The user is prompted for an initial base width value and step size (store

in the baseWidth HEADING structure) and for an initial water depth value and step

size (stored in the waterDepth HEADING structure). Thus the program computes 10

values for base width starting at the initial value and incrementing the base widths

using the step size; e.g. with a base width of 1.0 and step size of 0.5, the 10 base

width values used are 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5.

4. When creating a flow rate table (i.e. updating the global flow rate table structure),

prompt the user for a table name. Define a file name by adding the extension “.frt” to

the flow rate table name. Before updating the flow rate table structure, check that the

file can be created (in the current working directory). If the file already exists, prompt

the user to replace the file and continue the creation process only if the user accepts to

replace the current file. Use a data file (.dat) to store the contents of the flow rate table

structure.

5. Loading a flow rate table allows the user to select load a flow rate table from a flow

rate table file. The contents of the corresponding file are loaded into the flow rate

structure.

6. In the case of estimating depth, the user must provide a base width that occurs in the

table. The flow rate can fall between values and linear interpolation should be used to

estimate the depth. If the base width is not part of the table or the flow rate falls

outside the range of the table, an error message shall be printed.

7. Demonstrate structured programming by using a number of functions, that is, break

down the software into smaller problems to be solved by separate functions (note that

algorithms should be provided for each function). It will be much easier to develop

the software than trying to create large functions. For example:

8. Do not use global variables other than the single structure variable described above.

9. Use the metric system.

10. In Step 2, when describing input/output, you will be required to provide a textual

description since block diagrams will not be sufficient.

11. Test input data as follows:

1. The following values must be greater than zero: slope of water surface S, and

slope of the trapezoid side z, initial base width value, initial water depth value,

step sizes.

2. The Maning coefficient must fall between the values of 0.001 and 0.1.

3. Check for invalid selection values entered in response to the menus or other

prompts (e.g. prompt to request for overwriting a file).

12. Develop the pseudo code for the missing functions, and translate all into C code.

Main program :

Copy the empty string to flowRateTable.name

userInterface()

userInterface()

Repeat

Print “1) Create a flow rate table”

Print “2) Load an existing flow rate table”

Print “3) Display the currently loaded flow rate table”

Print “4) Estimate water depth using flow rate table”

Print “5) Terminate”

If flowRateTable.name not empty string

Otherwise

Repeat

Print “Please make a selection (1-5): “

If selection equals 1

Else if selection equals 2

Else if selection equals 3

displayFlowRateTable()

Else if selection equals 4

estimateWaterDepth()

Else if selection equals 5

Print “Terminating”

while selection less than 1 or greater than 5

while selection not equal to 5

if setFlowRateTableName() equals OK

Assign readValueGTzero(“slope of the water”) to flowRateTable.params.s

Assign readValueGTzero(“slope of the channel sides”) to flowRateTable.params.z

Repeat

Print “Please give the coefficient of roughness: “

If flowRateTable.params.n less than N_MIN or greater than N_MAX

Print “Coefficient of roughness must lie in the range of”,

N_MIN, “ and “, N_MAX

While flowRateTable.params.n less than N_MIN or greater than N_MAX

Assign readValueGTzero(“initial base width”) to flowRateTable.baseWidth.initialValue

flowRateTable.waterDepth.initialVal

ue

Assign flowRatetable.waterDepth.initialValue to y

Assign 0 to rix

Repeat while rix is less than NUMROWS

Assign flowRateTable.baseWidth.initialValue to b

Assign 0 to cix

Repeat while cix is less than NUMCOLS

Assign computeFlowRate(flowRateTable.params, b, y) to

flowRateTable.flowRates

[rix][cix]

Assign b+flowRateTable.baseWidth.stepSize to b

Increment cix

Assign y+flowRateTable.waterDepth.stepSize to y

Increment rix

(Store to the file)

Append “.frt” to flowRateTable.name and assign to fileName

If can open fileName for writing as filePtr

Write flowRateTable into file filePtr

Close file filePtr

Print “Table “, flowRateTable.name, “ created”

setFlowRateTableName()

/* This function should prompt the user for the file name, checks if the file exists

or not, and give the user the choice to overwrite it, and copy the table name into

the name field of the flowRateTable structure. This function returns a Boolean

value*/

/* This function should prompt the user for a positive value, and keep prompting

until the value is positive. This function returns that positive value */

computeFlowRate(params, b, y)

assign yb+y2*params.z to area

assign b+2y(1+params.z2)1/2 to perimeter

assign area/perimeter to rh

assign (1/params.n) * area * rh2/3 * params.s1/2 to q

return q

/* This function prompts the user for the table name, opens the file for reading,

and copy the file contents into the FlowRateTable structure */

displayFlowRateTable()

/* This function displays the flowRateTable on the output screen in a tabular

format */

estimateWaterDepth()

Repeat

Print “Please enter a base width: ”

Assign getColIndex(b) to cix

If cix equals -1

Print “Invalid base width value, must be in the table heading”

While cix equals -1

Repeat

Print “Please enter a flow rate: ”

Assign getRowIndex(cix, q) to rix

If rix equals -1

Print “Invalid value, must be in the range of the base width column”

While rix equals -1

If rix equals NUMROWS-1

Assign flowRateTable.flowRates[NUMROWS-1,cix] to waterDepthEstimate

Otherwise

Assign (qflowRateTable.

flowRates[rix][cix])/(flowRateTable.flowRates[rix+1][cix]

- flowRateTable.flowRates[rix][cix]) to stepFraction

Assign flowRateTable.waterDepth.initial+ flowRateTable.waterDepth.stepSize*rix +

stepFraction*flowRateTable.waterDepth.stepSize to waterDepthEstimate

Print “Water depth is estimated at “, waterDepthEstimate

getColIndex(bGiven)

Assign -1 to retValue

Assign flowRateTable.baseWidth.initialValue to b

Assign 0 to cix

Assign 0.001*flowRateTable.baseWidth.stepSize to tolerance

Repeat while cix less than NUMCOLS and retValue equals -1

If absolute value of b-bGiven less than tolerance

Assign cix to retValue

Increment cix

Assign b+flowRateTable.baseWidth.stepSize to b

Return retValue

getRowIndex(cix, qGiven)

/* this function returns the row index with the closest value to the qGiven value –

similar to the getColIndex function */

2. Is that all?

3. yes