The ; at the end of the for loop is taken as an empty statement, the equivalent of an empty block for your for-loop. The compiler is reading your code as:
int i;
....
for(i=0; i<9; i++)
/* no-op */;
/* inline block with no relation to for-loop */
{
System.out.println ("Please enter a number:");
Num[i] = keyboard.nextDouble();
Sum += Num[i];
Product *= Num[i];
}
Remove the ; to get your intended behavior.
If you don't need the i outside of the loop, you could move its declaration within the for statement.
for(int i=0; i<9; i++)
{
// `i` is only usable here now
}
// `i` is now out of scope and not usable
Using this syntax when the erroneous semicolon ; was present would have produced a compile error that would alerted you to the erroneous ; earlier. THe compiler would see this:
for(int i=0; i<9; i++)
/* no-op */;
/* inline block with no relation to for-loop */
{
System.out.println ("Please enter a number:");
Num[i] = keyboard.nextDouble(); // compile error now - `i` is out-of-scope
Sum += Num[i];
Product *= Num[i];
}
This would be an example why it is good practice to limit the scope of variables when possible.
iis not declared. Unless you haveideclared globally somewhere at the top.Num,keyboard,Sum, orProduct.