Loop Rewriting
Rewrite the following while statements as for statements. Assume that input (a Scanner) has been previously declared.
a. int count = 0;
int sum = 0;
while (count<10)
{
sum += input.nextInt();
count = count + 1;
}
b. int count = 1;
while (count < = 15)
{
int num = 1;
int sum = 0;
while (num < = 5)
{
sum += input.nextInt();
num += 1;
}
System.out.println("Sum number " + count + " is " + sum);
count+ + ;
}
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.