← all problems

printRectangle 🌶️

A sign painter marks out a rectangle with # characters. Write a method printRectangle that takes two ints, rows and cols (both 1 or more), and prints rows lines with cols characters # on each line. Use two loops: the outer one for the lines, the inner one for the characters on one line.

For example, printRectangle(2, 5) prints

##########