A java program to find the sum of squares.

Question:
A java program to find the sum of squares.

Code:
import java.util.Scanner;
 
public class SumOfSquares {
 
   public static void main(String[] args) {
 
      Scanner sc = new Scanner(System.in);
 
      System.out.print("Enter Integer: ");
      int n = sc.nextInt();
      System.out.println("You entered: " + n);
 
      int sum = 1;
 
      for (int x=2;x<=n;x++) {
        sum = sum + (x*x);
      }
      System.out.println(sum);
 
   }
}

Output:
$ java SumOfSquares
Enter Integer: 5
You entered: 5
55