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 da = 3;
int scontfae = 3;
double vu = 4.0;
int crod = 8;
double sor = 3.0;
double re = 2.0;

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

6 + 6 % 6 + 9 * da - 3 % scontfae / vu - crod / sor / 6 % re

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean vougn = false;
double mup = 3.0;
int penscas = 9;
int hi = 9;
double ir = 2.0;
boolean scre = true;
boolean idid = true;
double ooaf = 4.0;
boolean pano = true;
int i = 3;
double wi = 4.0;
int nen = 3;
boolean ciliam = false;

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

vougn == (mup == penscas) != hi >= ir == scre == idid || 3 == ooaf || pano == i >= wi != nen >= 6 == (2 == 5) && ciliam

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: