Publicité

Below is my code.How can i fix thisimport java.awt.;pu.pdf

aminaENT
1 Apr 2023
Below is my code.How can i fix thisimport java.awt.;pu.pdf
Prochain SlideShare
662305 10662305 10
Chargement dans ... 3
1 sur 1
Publicité

Contenu connexe

Plus de aminaENT(20)

Publicité

Below is my code.How can i fix thisimport java.awt.;pu.pdf

  1. Below is my code. How can i fix this? import java.awt.*; public class IfGrid { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(400, 400); panel.setBackground(Color.blue); Graphics g = panel.getGraphics(); int sizeX = 40; int sizeY = 40; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { int cornerX = x*sizeX; int cornerY = y*sizeY; if ((x + y)%2==0 ); g.setColor(Color.green); else g.setColor(Color.yellow); g.fillRect(cornerX, cornerY, sizeX-1, sizeY-1); g.setColor(Color.black); g.drawString("x="+x, cornerX+10, cornerY+15); // text is positioned at its baseline g.drawString("y="+y, cornerX+10, cornerY+33); // offsets from the corner do centering } } } } Make a checkboard pattern. Hint look at the sum x+y for the green squares. Copy your modified if statement into your solutions document.
Publicité