Write a program that asks the user for a positive integer no greater than 15. The program should then write to a
file called "output.txt" a square using the character 'X'. The number entered by the user will be the length of each
side of the square.
For example, if the user enters 5, the output.txt file should contain the following:
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
If the user enters 8, the output.txt file should contain the following:
XXXXXXXX
XX
XXXXXX
XXXXXXXX
Additional instructions:
●
●
●
Use while loop to validate the integer value between 1 and 15.
Don't forget to include "throws IOException" in the header of main().
Use PrintWriter class to print "X" to output.txt file.
Don't forget to use the PrintWriter class's close method to close the file.
Fig: 1