This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: (i) the number of triangles, and (ii) the sum of the areas of all red rectangles. SOLUTION: // Pseudocode to perform calculations on geometric shapes 1. Input n red, blue, green shapes ( ∆ → triangle and □ → rectangle) 2. Initialize ∆ count=0 <units>, □ area=0 <sq.units> 3. For each shape 4. If shape is a ∆ le 5. ∆ count++ 6. Else if (shape is a □ le && color = “red”) 7. □ area = ( l*b ) + □ area 8. return “Number of triangles = ” ∆ count “units.” 9. return “Total area of red rectangles = ” □ area “sq. units.” 2. Clear an oil spill (decide on your own input/ output parameters, strategies, etc.) [There are multiple ways to try to solve this problem. Ask BP! Your approach to the problem, strategies to break it into manageable steps, and the logical correctness of your pseudocode will be evaluated.]...
View Full Document
- Summer '08
- Algorithms, following problems, times table, red rectangles, input/ output parameters