 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
count = 0;
|
|
|
sum = 0;
|
|
|
notDone = true;
|
|
|
while ( notDone )
|
|
|
{
|
|
|
line = dataFile.readLine( ); // Get a line
|
|
|
if (line != null) // Got a line?
|
|
{
|
|
number = Integer.parseInt(line);
|
|
|
if (number % 2 == 1) // Is number odd?
|
|
|
{
|
|
|
count++;
|
|
|
sum = sum + number;
|
|
|
notDone = ( count < 10 );
|
|
}
|
|
}
|
|
else
// Reached
EOF unexpectedly
|
{
|
|
errorFile.println(“EOF reached
before ten odd values.”)
|
|
notDone = false; // Change flag value
|
|
}
|
|
|
}
|
|