please solve the following question using java format (*Solution can include*if needed* ( if statement, switch, while ) not arrays*)
Write a program which performs the following:
a) Prompts the user to enter a number N
b) Displays the square of each number that lies between 1 and N Example: Enter a value for N: 4 1,4,9