Write the method drawSquare below.
/** Precondition: 0 ≤ x < 10, 0 < y ≤ 10, and len > 0.
* Draws a square on a 10-by-10 xy-coordinate grid
* and prints the square’s side length and area.
* The upper left corner of the square will be located
* at the coordinate (x, y) and the side length of the * square will be len (or as large as will fit in the grid).
*/
public void drawSquare(int x, int y, int len)

Respuesta :

The method drawSquare is an illustration of functions; functions are named program statements that are executed when called

The method drawSquare

The method drawSquare written in Java, where comments are used to explain each action is as follows:

//This defines the function

public static void drawSquare(int x, int y, int len) {

//This checks if x + len exceeds 10

       if(x+len>10){

           len = 10-x;}

//This checks if y + len exceeds 10

       if(y+len>10){

           len = 10-y;}

//The next four lines draw the square

       drawLine(x, y, x+len, y);

       drawLine(x+len,y,x+len,y-len);

       drawLine(x+len, y-len, x, y-len);

       drawLine(x, y-len, x, y);

   }

Read more about java programs at:

https://brainly.com/question/19271625