Learn to Program with ZedLX

Free Online Programming Course for Beginners

Count and Sum [8/8]

This program calculates the sum of 9 random numbers.

After running and examining the program, modify it so that it sums up only those numbers that are smaller than 10. To accomplish that, use an if statement.

Solution

	...
	if x<10
	    {
	    sum += x;
	    println " Sum so far: ", sum;
		}
	...
			

Loading...