title: Java Print the perfect squares less than an input using a while loop
body: <p>This is a homework assignment that I am stuck on that maybe someone could help me with:</p>
  
  <p>"Write a program using a while loop that prints the perfect squares less than an input 'n'. For instance, if n=30, print 25, 16, 9, 4, 2, 1, 0,"</p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.Scanner;
  public class fourpointone {
  
      public static void main(String[] args) {
  
          int input, output;
  
          System.out.println("Please enter an integer");
          System.out.println();
  
          Scanner num= new Scanner(System.in);
          input = num.nextInt();
          System.out.println();
  
          while(input&gt;=0){
  
              System.out.println(Math.pow(input, 2));
              --input;
  
          }
          System.out.println();
          System.out.println("are the perfect squares less than your input");
      }
  
  }
  </code></pre>
  
  <p>It gives me all the perfect squares below my input squared. Like I get the squares 49 on down if I enter 7. I thought maybe there's a way for it to only print the result below the value of the input but I don't know how to do that. There's probably a more simple way to do the whole thing but I haven't figured it out so far. </p>