Hello, I'm just starting to learn Java, and for a summation program that we started in class, I've been stuck on the question as to why this brings up an error message when I try to build it. Please advise me.
import java.util.Scanner;
public class summation{
public static void main(String[] args){
int n;
int s=0;
Scanner X=new Scanner(System.in);
System.out.print("Enter # of terms: ");
n = X.nextInt();
for(int i=1; i <= n; i=i+2);
{
s= s+ i;
}
System.out.print(+s);
}
}
The exact probem shows that within the for loop, the i is not found.
for(int i=1; i <= n; i=i+2);
{
s= s+ i;
^
}