Hi, everyboday,
For following question:
Write a
Java application to print a list of numbers from 1 through 30 and the sum of the numbers as they are printed. Thus,
1
2 3
3 6
4 10
etc.
I wrote the following code:
public class Count {
public static void main (
String args[]) {
int i = 1;
int sum = 0;
}
for (int i; i<100; i++){
sum = sum + i;
}
System.out.println(i +" "+ sum"\n");
}
When I tried to compile it, the following error info. came up:
1. Count.java:6: illegal start of type
for (int i; i<100; i++){
^
2. Count.java:9: <identifier> expected
System.out.println(i +" "+ sum"\n");
^
I amself can't figure out the problem and would highly appreciate if someone in this forum give me a lead! Thanks so much!
luk