I am new to coding and have started with C. In the question I am working through, it is asking to develop software that allows the user to study how the total force will vary with water depth for the type of dam presented. (total force of the pressure of water exerted on a dam)
The equation given to use is: F(d)=pg(h/2)[bd+(2Ʃw(zi)(d-zi))],
**[the sigma in the equation has index i=1(bottom of sigma) and finishes at n-1(top of sigma)]
**[this equation was determined by using the trapezoidal rule for integration]
Where,
F(d) = the total force for the depth d;
p = the density of water (assumed to be 10^3 kg/m^3);
g = acceleration due to gravity (9.8 m/s^2);
b = the width of the channel base;
d = elevation (in m) of the water above the channel bottom;
h = d/n; **(I am also confused on what n would be)**
a = is the distance from the edge of the channel base to the bank of the channel;
b = the width of the channel base;
D = the depth of the channel;
zi = z(i-1)+h for i=1,2,...,n-1;
w(zi) = (2a/D^2)(zi^2)+b
It also states... The user will provide the following input:
• dam and channel dimensions (values of a, b, D),
• the range of water depth d (that is both a minimum and maximum value for the depth),
• An increment value for the depth d to for plotting the total force ft(d) (integration is used to find the force ft for each value of the depth d).
So my question is aimed at the last two bullets above. How would I ask the user to input the range of water depth d and the increment value for d?
With the research that I have done, I believe I could create some kind of sorting function that will run a number of passes on an array (which contains the Min and Max values inputted by the user) and have the lowest number inputted as the minimum value and the largest number inputted as the maximum value. I would also need to make a loop over passes for this method to work. I could be very wrong about this as I am new to programming.
Is there an easier, less complicated way to do this? Like, would I be able to somehow simply ask the user to "enter a value for Min", "enter a value for Max" and "enter the increment value" (or something along those lines)?
Any suggestion will help, thanks in advance!!