Design a for loop that gets 6 integer numbers from a user, accumulates the total of them, then displays the accumulated total to the user. Just write the code segment to show what is asked, not a complete program. However, declare any variables that you need to use. Use a semicolon (;) at the end of each line of code so I can tell when you use a new line in your code.

Respuesta :

Answer:

Explanation:

The following loop code is written in Java and asks the user for the 6 integer numbers as mentioned in the question and sums them up. Finally putting them into a variable named total and printing it out.

       int total = 0;

       for (int x = 0; x < 6; x++) {

           Scanner in = new Scanner(System.in);

           System.out.println("Enter an integer: ");

           total += in.nextInt();

       }

       System.out.println("Your total is: " + total);

ACCESS MORE