/**
*
* Beschreibung
*
* @version 1.0 vom 22.06.2013
* @author
*/
import java.io.*;
public class asd {
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("How many numbers do you want to be generated?");
String text = "";
try{
text = in.readLine();
}catch(IOException ioe){
}
int sum = 0, num=0;
for (int i=0; i<Integer.parseInt(text); i++) {
num = (int) (Math.random()*10000);
System.out.println("Number "+(i+1)+": "+num);
sum += num;
} // end of for
System.out.println("Sum of all: "+sum);
} // end of main
} // end of class asd
you need to save this thing into “asd.java” and run it then.