Name:
___________________________
Name.##:
___________________________
Fill in the following tracing tables, save your result as a PDF, and upload it to the Carmen dropbox. Note that if you want to practice for the exam, you should print these pages and fill them out by hand as that is how we will be doing the exam.
1. For the following program segment, fill in the tracing table below as described in the course notes.
String str = Hello World!; int test = 6;
String output = ;
if (test >= str.length()) { } output = Bigger!;
else {
output = Smaller!;
}
String output = ;
Statement
______________
Program State
String str = Hello World!;
str =
int test = 6;
______________
str = test =
_____
str = test = output =
if (test >= str.length()) {
______________
_____
______________
output = Bigger!;
str = test = output =
______________
_____
______________
str = test = output =
}
else {
______________
_____
______________
str = test = output =
output = Smaller!;
______________
_____
______________
}
str = test = output =
______________
_____
______________
str = test = output =
______________
_____
______________
2. For the following program segment, fill in the tracing table below as described in the course notes.
NOTE: Adobe Acrobat does not allow you to use a strike-out font when filling in forms, so if your PDF viewer does not allow you to strike out values that is fine just make sure you clearly space out your result for each iteration.
int n = 9431; String output=; while(n > 0) {
intx = n % 10;
output = output + x;
} n = n / 10;
Statement
Program State
int n = 9431;
String output = ;
n=
______________
n=
while ( n > 0 ) {
______________
output =
__________________________
int x = n % 10;
n=
______________
output =
__________________________
n= x=
______________
output =
__________________________
______________
output = output + x;
n= x=
______________
output =
__________________________
n = n / 10;
n= x=
______________
______________
output =
__________________________
______________
}
n=
______________
output =
__________________________
Reviews
There are no reviews yet.