Challenges

Remember the rules for this are

  • Try to use only the information given up to this point in this book.
  • Try not to give up until you've given it a solid attempt

Challenge 1.

Write a method named printSquare which takes one int argument named size.

The size argument should control how big of a square is output.

// CODE HERE

void main() {
    printSquare(4);
    System.out.println();

    printSquare(3);
    System.out.println();

    printSquare(2);
    System.out.println();

    printSquare(1);
    System.out.println();
}

Challenge 2.

What happens if a negative number is given to your printSquare?

Make it so that if a negative number is given, it works the same as if a positive number was given.

// CODE HERE

void main() {
    printSquare(3);
    System.out.println();
    printSquare(-3);
    System.out.println();

    System.out.println();
    printSquare(-2);
    System.out.println();
    printSquare(2);
}

Challenge 3.