Iteration Exercises
1. Iteration Exercises 1. Below is a variation on the tiling exercise from two weeks ago. In this exercise you are to develop a program using a for loop, that will allow any number of shaded areas to be entered and the area to be tiled calculated.
Although the diagram below
includes 4 shaded areas your program should be able to work with any positive
integer number.
[Specimen
answer]
2. One of the disadvantages with stipulating the number of shaded areas is that a miss-count could occur, the program would therefore expect another shaded area that does not exist, or terminate before the last shaded area is entered.
Using either a while loop
or repeat loop, amend your previous program to enable the user to enter shaded
area dimensions until the user decides to quit.
[Specimen
answer while loop]