Hello. :)
I was wondering whether anybody could possibly tell me why, the below Java program doesn't output anything to the screen when I run it. :confused:
It's supposed to print the sum of square numbers between 1 and 10. It compiles without a problem, but for some reason when I try to execute it, it just jumps straight to the end of the program and I have no idea why?
Any help/assistance would be greatly appreciated. :)
I was wondering whether anybody could possibly tell me why, the below Java program doesn't output anything to the screen when I run it. :confused:
It's supposed to print the sum of square numbers between 1 and 10. It compiles without a problem, but for some reason when I try to execute it, it just jumps straight to the end of the program and I have no idea why?
Code:
import java.util.*;
public class SquareProgram {
public static void main(String args[])
{
int n = 10;
int square = n*n;
square(0);
sumOfSquares(0);
}
public static int square(int n)
{
int square = n*n;
return n*n;
}
public static int sumOfSquares(int n)
{
int sum = 0;
int square = n*n;
int i;
for (i = 1; i <= n; i++)
{
sum = sum + square;
System.out.println("The sum of squares between 1 and "+n+" is "+sum+"");
}
return sum;
}
}