Algorithm for Computing the Area Under a Curve

One way for computing the approximate area under a curve is by computing the sum of the areas of the rectangles as shown in the diagram above. Each rectangle has the same width and a length determined by the Y value on the curve. Write an algorithm that reads in the number of Y-data points, the width of each rectangle (W) and then reads in all the Y-data points
(). The algorithm should then iteratively compute the area of each rectangle for each of the Y-data points and accumulate the total. After all points have been processed the algorithm should print the total area.