Question
write a program that displays a checkered pattern of alternating blue and green squares. The colors should alternate in both the vertical and horizontal directions:
write a program that displays a checkered pattern of alternating blue and green squares. The colors should alternate in both the vertical and horizontal directions: it doesnt matter what the starting color (whichever cell you choose) is. The size and number of squares are input by the user. The required interaction is given below. The program should be structured to have three functions. 1) draw_square() with four parameters. This function draws a single square at a specified location with a certain size and filled with a certain color.
a) x the x coordinate of the point where the square is to be placed,
b) y the y coordinate of the point where the square is to be placed,
c) width, the length of the side of the square, and
d) color, the color to be used for filling the square. You are free to determine what the exact meaning of x and y are: for example, they could reference the top-left corner of the square.
2) draw_pattern with two parameters. This function calls draw_square() to draw a cer
a) width the length of the side of the smaller square and
b) number of squares, the number of squares in each row or column
3) main() with no parameters. This function gets the number of squares and the length of a side from the user and calls the function draw_pattern
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started