I'm having trouble with my logic and reasoning with a while loop, and returning the sum of positive numbers n, and the sum of inputs n squared. Please see my code and assist when possible, thank you.
The exercise was: /* Write a short Java method that takes an integer n and returns the sum of the squares of all positive integers less than or equal to n. * */
public class ch1dot7
{
public static void main (String[]args)
{
Scanner input = new Scanner(System.in);
int n, m = 0, sum = 0;
System.out.print("Please enter a value for n: ");
n = input.nextInt();
System.out.println("n is currently: "+n);
if (n <= 0)
{
System.out.print("Please enter a value that is higher than 0 (integer)");
n = input.nextInt();
}
while (sum > n)
{
System.out.print("Please enter a value for m (enter a value greater than n to exit): ");
m = input.nextInt();
if (m < n)
{
sum += m*m;
System.out.println("sum of the squares is: " +sum);
}
sum += m*m;
}
}//end main
}//end class