Need my services? Get in touch if you need a specialized PHP or Swift developer for your project in 2026, or learn more.

9.1.7 Checkerboard V2 Answers -

import acm.graphics.*; import acm.program.*; import java.awt.*; public class Checkerboard extends GraphicsProgram

A: Check your x and y calculations. x = col * size ensures the first column starts at 0. If you accidentally add an offset, correct it. 9.1.7 checkerboard v2 answers

public void run() // Loop through each row for (int row = 0; row < NUM_ROWS; row++) // Loop through each column in the current row for (int col = 0; col < NUM_COLS; col++) // Calculate the x and y coordinates for this square int x = col * SQUARE_SIZE; int y = row * SQUARE_SIZE; // Create a new GRect (square) GRect square = new GRect(x, y, SQUARE_SIZE, SQUARE_SIZE); square.setFilled(true); // Determine the color based on the checkerboard pattern // Even sum starts with RED at (0,0) if ((row + col) % 2 == 0) square.setColor(Color.RED); else square.setColor(Color.BLACK); // Add the square to the canvas add(square); import acm

Even with the correct code, students often hit frustrating roadblocks. Here’s a quick troubleshooting table: public void run() // Loop through each row

A: No. Some versions of 9.1.7 use black and gray. If the sample image shows gray, replace Color.RED with Color.GRAY .

private static final int NUM_ROWS = 8; private static final int NUM_COLS = 8; private static final int SQUARE_SIZE = 50; // Pixels per square