Electrical and Computer Engineering
13 of 14
UAH
CPE 112
Problem-Solving Case Study:
Finding the Area Under a Curve
•float RectArea( /* in */ float leftEdge,    // Left edge of
•                                            //   rectangle
•                /* in */ float width )   // Width of rectangle
•// Computes the area of a rectangle that starts at leftEdge and is
•// "width" units wide. The height is given by the value
•// computed by Funct at the horizontal midpoint of the rectangle
•// Precondition:
•//     leftEdge and width are assigned
•// Postcondition:
•//     Function value == area of specified rectangle
•{
•    return Funct(leftEdge + width / 2.0) * width;
•}