Hello Lizard and welcome to the Java Programming Forums
You were very close with this.. You just needed to do the calculation.
import java.util.Random;
import java.util.*;
public final class Sum10RandomIntegers {
public static final void main(String[] args) {
int sum = 0;
int randomInt;
[B]int result = 0;[/B]
System.out.println("Generating 10 random integers in range 0 to 10.");
Random randomGenerator = new Random();
for (int random = 1; random <= 10; ++random) {
randomInt = randomGenerator.nextInt(10);
sum = (int) (Math.random() * 10);
System.out.print(sum + " ");
[B]result = result+sum;[/B]
}
System.out.println();
System.out.println("Result = " + result);
}
}
Example output:
Generating 10 random integers in range 0 to 10.
8 5 3 5 3 7 8 6 3 5
Result = 53