Find the Error
Fix all syntactical and logical errors in the following segments. Assume that input (a Scanner) has been previously declared.
a. int count = 0; int number;
int sum = 0; // sum of the positive numbers among the first 15 numbers entered interactively while count<15
{
number = input.nextInt();
if (number > 0)
sum = sum + number;
}
b. for (int i = 10, sum = 0; i > 5; i++) // sum of the squares of 5 numbers entered interactively
{
int number = input.nextInt();
sum = number * number;
}
c. for (int i = 1, sum = 0; i < = 10; i++)
sum += i * i;
System.out.println ('The sum of the first 10 squares is " + sum);
d. // adds numbers entered interactively using —999 as a flag.
while (input.nextInt() != − 999)
sum = sum + input.nextInt();
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.