Answer:
import java.util.Scanner;
public class num8 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n= 0;
for(int i = 1; i<=10; i++){
System.out.println("Enter the values");
n += in.nextInt();
}
}
}
Explanation:
- A complete Java program implementing the solution is given above.
- The Scanner class is imported to allow for user input
- The variable n is declared and initialized to 0.
- Using a for loop, the user is repeatedly asked to enter a value
- The value is added to the variable n with this statement n += in.nextInt();
- The for loop condition for(int i = 1; i<=10; i++) ensures that it runs only ten times.