Hello, I'm starting to learn Java and this one of my homework but for some reason it won't run. My algorithm is to just add all 1-1000. I highlighted the part that's causing a problem in red. Please help, thanks!
import java.util.*;
public class thousand
{
static final Scanner in = new Scanner ( System.in );
public static void main(String[] args)
{
int n = 1000;
int total = n(n+1)/2;
System.out.println ("%i" + total);
}
}
This is the error code:
thousand.java:10: cannot find symbol
symbol : method n(int)
location: class thousand
int total = n(n+1)/2;
^
1 error