261
while(i <= limit && !finished)
{
number = Integer.parseInt(dataFile.readLine());
if(number > 0 )
sum = sum + number;
else if(number == 0 )
finished = true;
i++;
}
out.print("End of test. "+ sum + " "+ number);
and these data values:
5 6 –3 7 –4 0 5 8 9
a.What are the contents of sumand numberafter exit from the loop?
b.Does the data fully test the code? Explain your answer.
17.What is the output of the following code segment? (All variables are of type
int.)
i = 1 ;
while(i <= 5 )
{
sum = 0 ;
j = 1 ;
while(j <= i)
{
sum = sum + j;
j++;
}
System.out.print(sum + " ");
i++;
}
18.The physical order of the statements in an application is the order in which the
statements are _____ (written, executed).
19.The logical order of the statements in an application is the order in which the
statements are __ (written, executed).