All pastes #270517 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-12-07 12:54 UTC
rendered paste body
1. Problem Requirements

   -Find the depth of the water when there is an amount of 1000 cubic
    feet per second flowing through the channel.

2. Analyze the Problem

   -Define width (15), flow of water (1000), N (.014), S (.0015)
   -User inputs a depth value so R can be solved
   -Input: user guess as to the depth required
   -Fundamental process: Manning's equation
			 Q = (1.486/N)*AR^(2/3)S^(1/2)
                         R = (depth * width) / (2.0 * depth + width)
   -Limitations: depth cannot be negative

3. Design the Algorithm

   -After user enters depth, the program must solve for R before it
    can solve for Q
   -A while loop can be used for when depth is less than 0
      ex. while (depth < 0)
	  {
          cout << "Not a valid input.";
	  }   
   -An if/else statement can be used for when the percent the user is off
    is greater than 1%
      ex. if ((flow - target / 10) > 1)
          {
	  cout << "You were off by x percent";
	  }
	  else
	  {
	  cout << "You were only off by x percent, nice job";

4. Implement the Algorithm

   -Program will display the cubic feet per second when the depth is
    5.0 feet
   -User will be prompted to enter a guess
   -If the depth entered would produce a cubic feet per second number
    of greater or less than the 1% error given, find the difference
    and display how far off the user was
   -If the depth entered would produce a cubic feet per second number
    equal to 1000, congratulate the user