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.

1.  Input N (the number of Y-data points)
2.  Input W (width of each rectangle)
3.  Input 
4.  Set total_area to 0
5.  Set i to 1
6.  While i < N do
7.	Set area to W * 
8.	Set total_area to total_area + area
9.	Set i to i + 1
10. Endwhile
11. Output total_area
12. Halt