|
|
It can be simplified as follows: Total area = h * (a + b + b + c + c + d + d + e) / 2 = h * ((a + e) / 2 + (b + c + d)) and this appears to be the algorithm used by the OP. 1. calculate (a + e) / 2 2. use a loop to calculate (b + c + d) 3. Finally, multiply the total from parts 1 and 2 by h. |
It can be simplified as follows: Total area = h * (a + b + b + c + c + d + d + e) / 2 = h * ((a + e) / 2 + (b + c + d)) and this appears to be the algorithm used by the OP. 1. calculate (a + e) / 2 2. use a loop to calculate (b + c + d) 3. Finally, multiply the total from parts 1 and 2 by h. |
G3PO wrote: |
---|
Now I just need to have the program ask the user if they want to calculate the area using rectangles, trapezoids or both. The code I have uses the area for trapezoids. What would be the most efficient way to loop it? |
|
|
|
|
I don't know how important it is to perform this efficiently (probably a matter of opinion). The main priority I think is getting the correct answer. |