Sum numbers 1 through 10
Posted on 2006-10-25
I can't quite get the running total correct. I am supposed to sum the numbers 1 through ten and print the result.
My numbers are off.
public class Sum
public static void main(String args)
int total = 2;
for(int i = 1; i <= 10; i++)
total += i;
System.out.printf("i = %d\n",i);
System.out.printf("total= %d\n", total);
Any help would be greatly appreciated.