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:

double tepons = 3.0;
int scriua = 9;
double bre = 5.0;
int ingposs = 4;
int preolblak = 7;
int lun = 4;
double ce = 5.0;
int olbe = 2;

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

7 + 3 - tepons % scriua - bre % (5 / ingposs / 5 * preolblak + lun - ce) / olbe

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

double locdad = 4.0;
int al = 3;
double ok = 4.0;
boolean il = false;
boolean prothin = true;
boolean sossil = false;
double he = 5.0;
double planod = 2.0;
int fucsed = 8;
int esmo = 7;
boolean piaxresm = false;

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

7 < 4 || (7 > locdad || al == ok || !il != prothin) == sossil != !(5 >= he) != !(!(planod > 6)) && 8 >= fucsed || 4 <= esmo && piaxresm

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: