Question: For Assignment 1 , you drew a 4 x 4 checkerboard of black - and - white squares. Back then, the code to do this

For Assignment 1, you drew a 4x4 checkerboard of black-and-white squares. Back then, the code to do this
was rather tedious; you needed to write a call to rect() for every square (or maybe for every 2nd square,
depending on your approach) on the board.
For this question, you will revisit this problem by drawing a full-sized 8x8 checkerboard on the canvas. But
this time, you will use loops to do it.
Figure 3: An 8x8 black and white checkerboard
Your task is to draw a 8x8 black and white checkerboard in Processing that fills the entire space of a
200x200 pixel canvas. Have the top-left most tile coloured white like in the figure. Your solution is not an
interactive program, so you wont need to use functions like setup() or draw().
For this question, you must use loops to draw the checkerboard. Your code itself should contain only a
single call to the rect() function. Use loops and extra variables as needed to keep track of (a) where to
draw the current square, and (b) what color the current square should be (black or white).
Hint: When you did this question for A1, you may have used setting the background color to either
white or black as a shortcut to avoid extra calls to rect(). Now that you are using loops, you will
probably find that same shortcut just makes your logic more complicated to follow (and wont make
your code any shorter anyway), so you might want to avoid it. Its up to you though

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!