Hi everyone,
I've found these instructions in a C++ exercise book, and wondered if anyone could have a try, because I am not able to make my program work. It was mentioned in the text book, that it is a difficult program to write, could anyone send me a sample program for this problem. Thank you.
This is the problem:
Please write a C++ program to calculate the flow discharge of an open channel by using Manning’s
formula:
The Manning's coefficient n is given by Strickler equation as:
Hydraulics radius R = A / P, where P is wetted perimeter (the perimeter of the cross sectional area
that is "wet.")
Slope, S, is ranging from 0.0001 to 0.001 with a specific increment (the value will be entered by user,
say 0.0001); and for each slope (S), d (the mean bed particle size) varies from 0.2 mms to 2.0 mms
with a specific increment (the value will be entered by user as well, say 0.2).
The cross-section is formed by serials of points which are defined by horizontal distances Xi from the
left bank and depths Yi below the top of the capping beam on the left bank.
Fig. 1 open channel cross-section
Part A.
A1. The programme should operate as follows:
• Request the user to enter the number of points and then asks for the co-ordinates of each point
relative to the top of left bank.
Page 2 of 2
Hint: Use a loop and store the x and y co-ordinates of each point of the cross-section in separate
arrays.
• Request the user to enter the slope increment for open channel, for example, 0.0001.
• Request the user to enter the increment for mean bed particle size, for example, 0.2.
• Display the co-ordinates of each point. (Use a loop.)
• Calculate the distances between all points.
Hint: Use the following formula to calculate the distance between any two corners i and i-1:
( ) ( )2
1
2
−1 − − + − i i i i x x y y .
• Display the distances between all points, for example:
The distance between point 1 (-2, 2) and point 2 (1, 7.2) is: 6.0
The distance between point 2 (1,7.2) and point 3 (6,7.5) is: 5.01
• Calculate and display the wetted perimeter of the open channel cross-section.
• Calculate and display the cross-sectional area of the flow.
• Calculate and display the Hydraulics radius.
• Calculate and display the flow discharge.
Hint: Consider a polygon made up of line segments between N vertices (Xi,Yi), i=0 to N-1. The last
vertex (XN,YN) is assumed to be the same as the first, i.e. the polygon is closed.
Use the following formula to calculate the area of a polygon:
See
http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ for more detail (pdf also attached)
• The user should be able to repeat these steps as many times as required.
A2. Test your programme. Provide sufficient evidence of testing.
Part B.
B1. Implement a simple option menu to make your program easier to use.
B2. Improve your program - Consider cases such as choosing an option that is not available in the
menu, starting from option 2,3, etc. instead of 1, entering a negative number of points, entering the
same co-ordinates for two or more corners, etc.), writing the results in a file, etc.; Provide an option to
change the number of points or their co-ordinates without exiting the menu or re-entering those coordinates
that remain unchanged;