0% found this document useful (0 votes)
14 views2 pages

Tracing Problem2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

Problem Set:

import java.util.Scanner;
public class Tracing2
{
public static void main(String[] args)
{
int k = 109;
do
{
for(int i = 3; i < 9; i = i * 2)
{
if(k % i == 3)
k = k / 3;
else
k = k / 2;
}
System.out.println(k);
}while(k > 0);
for(int i = 0; i < 2; i++)
{
for(int j = 0; j < 2; j++)
{
for(int m = 0; m < i * 2; m++)
{
if(m == j && m == i)
{
System.out.println("i: " + i);
System.out.println("j: " + j);
System.out.println("m: " + m);
}
}
}
}
}
}
Output Memory box
27 K=109,54,27,13,6,3,1,0
6 I=3,6,12,3,6,12,3,6,12,3,6,12
1 I=0,1,2
0 J=0,1,2,0,1,2
I:1 M=0,0,0,0,1,2,0,1,2
J:1
M:1

You might also like