2In the following program segment, which variable is the loop control variable (also known as the counter variable) and which is the accumulator? int num, num1 = 0, num2 = 0; Loop Control Variable: _____________________ Scanner keyboard = new Scanner(System.in); while (num1 < 10) { Accumulator: _____________________ System.out.print("Enter a number: "); num = keyboard.nextInt(); num2 += num; } System.out.println("The sum is " + num2); 3Correct the errors in the following code segment. // This code contains ERRORS! // Print the numbers 1 through 10. for (int count = 1, count <= 10, count++;) { System.out.println(count); count++; } please solve two of them
- 2In the following program segment, which variable is the loop control variable (also known as the counter variable) and which is the accumulator?
int num, num1 = 0, num2 = 0; Loop Control Variable: _____________________
Scanner keyboard = new Scanner(System.in);
while (num1 < 10) { Accumulator: _____________________
System.out.print("Enter a number: ");
num = keyboard.nextInt();
num2 += num;
}
System.out.println("The sum is " + num2);
- 3Correct the errors in the following code segment.
// This code contains ERRORS!
// Print the numbers 1 through 10.
for (int count = 1, count <= 10, count++;) {
System.out.println(count); count++;
}
please solve two of them
Trending now
This is a popular solution!
Step by step
Solved in 3 steps