Write a method ‘squareOfAsterisks’ that displays a solid square (the same number of rows and columns) of asterisks whose side is specified in an integer parameter ‘side’. For example, if side is four, the method should display:
****
****
****
****
Your main method will look a lot like this.
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
// prompt for input
while (input.hasNext()) {
int numAsterisks = input.nextInt();
squareOfAsterisks(numAsterisks);
// prompt for input
}
}
Your squareOfAsterisks method will look a lot like this:
private static void squareOfAsterisks(int numberOfAsterisks)
{
// Loop for the specified number of rows
// Loop for the specified number of columns
// print an asterisk
// print a new line after the last asterisk
// in this row
}
I think that’s pretty straightforword. The solution will be available here after the end of next week’s class.