Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

variable i declared at line 16? variable k declared at line 7? variable k declar

ID: 3551464 • Letter: V

Question





variable i declared at line

16?

variable k declared at line

7?

variable k declared at line

26?

program. What is the final output? Keep in mind the

scopes of the variables while making your trace table. How

many columns will it need? (Trace the program first, then

type it into Eclipse to verify your answer).





1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 public class WhatzitRevisited {     public static void main(String[] args) {         int i = 50;         int j = 0;         while (i > 0) {             int k = whatzitTheFirst(i);             j = j + k;             i = i / 10;             System.out.println("Main Loop");         }         System.out.println("The final value is: "+j);     }          private static int whatzitTheFirst(int j) {         int i = 50;         int k = 5;         while (k < j) {             System.out.println("First Whatzit");             i = i - whatzitTheSecond(j);             k = k*10;         }         return i;     }          private static int whatzitTheSecond(int k) {         int j = 2;         int i = 0;         while (j > 0) {             System.out.println("Second Whatzit");             i = i + k;             j = j - 1;         }         return i;     } }

Explanation / Answer


- Line to 23 are in scope with i


- Line 7 to 10


- Line 26 to 34 (method argument, valid for through out method definition)


-


output :


The final value is: 0