So you simply make this: sum=sum+num; for the cycle. For example sum is 0, then you add 5 and it becomes sum=0+5 , then you add 6 and it becomes sum = 5 + 6 and so on.
Read moreHow do you find the average between two numbers in Java?
Java program to find the average of two numbers:
Read more