Please help... assignment for school
Write a Java program that prompts the user to enter the size of a square from 1 to 20 (inclusive) and then displays a hollow square of that size made of the character uppercase ‘X’. If the user inputs an invalid number, the program should prompt them repeatedly until their input is in the allowable range.
Examples of the output:
Enter the square size from 1 – 20: 7
XXXXXXX
X______X
X______X
X______X
X______X
X______X
XXXXXXX
Enter the square size from 1 – 20: 1
X
Enter the square size from 1 – 20: 2
XX
XX
So far i got this:
import java.util.Scanner;
public class Square1 {
public static void main(String[] args) {
Scanner keyInput = new Scanner(System.in);
int lo = 1;
int hi = 20;
int squareSize;
do
{
System.out.print("Enter the square size from 1 - 20: ");
squareSize = keyInput.nextInt();
}
while (squareSize >= lo ^ squareSize <= hi);
}
}