i have this problem with regards to java data

the problem accepts input number and then output the sum of the square from 1 to the n(1 to the no. input) thus, if the input is 4 the output should be 288 because:

1 raise to 1 + 2 raise to 2 + 3 raise to 3 + 4 raise to 4

1 + 4 + 27 + 256 = 288

i have my code but i'm stuck gotta help me outta here

```
import javax.swing.*;
public class RRunner {
public static void main(String[] args){
int i; // counter
int num; // number to be input
int pw; // power of sum
num = Integer.parseInt(JOptionPane.showInputDialog("Enter a number: "));
for( i=1; i<=num; i++ ){
pw = (num*num) + i;
System.out.println("The answer is "+ pw);
}
}
}
```