Drawing ASTs for expressions: Correct Solution


For each of the Java expressions below:

Be sure that your tree accurately reflects how Java would evaluate the expression.

Part 1

Given the following variables:

int hipspas = 7;
double skerthial = 1.0;
int ploeosm = 7;

...draw the AST and evaluation results for the following expression:

0 % 6 + hipspas / 9 + skerthial - 6 + ploeosm + 9 - 7 % 2 / 1 % 6

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean sogor = true;
boolean toal = true;
boolean deicceng = false;
int feseng = 7;
boolean e = true;
boolean il = true;
boolean ocpud = true;
boolean sust = false;
boolean le = false;
double pahu = 2.0;
boolean tiloss = true;

...draw the AST and evaluation results for the following expression:

sogor == !toal || !deicceng == feseng <= 3 || !e || il == ocpud || sust != le || pahu >= 3 || tiloss

Solution

Things to double-check in your solution:


Part 3

Draw the AST and evaluation results for the following expression:

(0 + 1 + 2 + 3 + 4 + 5 + "6" + 7 + 8 + "9" + 10 + 11) + 12

Solution

Things to double-check in your solution:


Related puzzles: