Uploaded by arushi.madhu

Program Trace Table Example

advertisement
PROGRAM TRACE TABLE for <Trace_VariablesAndExpressions>
Line #
Program Statement
numStudents
percentFull
4
System.out.println("Hello world!");
6
int numStudents = 22:
22
8
double percentFull = numStudents / 34.0;
22
0.64705882
35294118
10
System.out.println("The classroom is
this percent full:");
22
0.64705882
35294118
11
System.out.println(percentFull);
22
0.64705882
35294118
15
System.out.println("Making changes");
22
0.64705882
35294118
16
numStudents = 28;
28
0.64705882
35294118
22
percentFull = numStudents / 30.0 *
100;
28
93.3333333
3333333
28
System.out.println("The new classroom is
" + percentFull + "% full (output
version #1)");
28
93.3333333
3333333
36
System.out.print("The new classroom is
");
28
93.3333333
3333333
37
System.out.print(percentFull);
28
93.3333333
3333333
38
System.out.println("% full (output
version #2)");
28
93.3333333
3333333
OUTPUT:
Line #
Program Output
(please list this exactly as it appears on the screen)
(NOT what is listed in the program source code)
4
Hello World!
10
The classroom is this percent full:
11
0.6470588235294118
15
Making changes
28
The new classroom is 93.33333333333333% full (output version #1)
36,
37,
38
The new classroom is 93.33333333333333% full (output version #2)
Directions:
●​ Fill in the name of the program at the top of the page
●​ The program execution starts on the first line inside the public static void
main (String[ ] args).
○​ Anything before that is left out of the trace (those are used by the compiler).
●​ Make sure that you include the line numbers in your trace so it’s clear in what
order the program is running.
●​ PROGRAM TRACE TABLE Columns
○​ Put one variable per column; feel free to adjust the size of the font and/or
the column width to make the columns fit
○​ Copy the variable's name from the source code and paste it into the column's
first row (sometimes called the 'column header') so that the column's name is
exactly identical to the variable's name.
■​ It's fine if the name of the variable spills over onto the next line
●​ PROGRAM TRACE TABLE Rows
○​ On a row before a variable is defined, you MUST put a dash (-) in its column
to indicate that the variable isn’t in existence yet.
○​ On a row where a variable(s) changes, you MUST format the value in its
column very distinctly (highlight in color, change font and/or size) to make it
easy for your instructor to see what's changed (if anything) on each line.
■​ If you are using Google docs, click on the button called Normal Text
and change it to Header 1 to achieve this!
●​ Output from the program should be listed in the OUTPUT table.
○​ Make sure to fill this in as you trace through the program (don't fill it in
before the trace– the whole point is to practice tracing what the program is
doing without having to run it so don't just copy the output from theIDE you
are using. Don't fill it in after the trace – the whole point is to accurately
simulate what the computer will do with your program)
○​ At the same time you are not expected to predict things like round off errors,
nor are you expected to do the long division by hand (feel free to use a
calculator).
●​ Tips:
●​ Delete any extra columns or rows at the end of the trace
●​ Resize any of the rows & columns for better readability by dragging the
borders of the column or row.
Download