Question
Trace the execution of the following statements by filling in the tables to the right of the statements. The tables maycontain too many or too
Trace the execution of the following statements by filling in the tables to the right of the statements. The tables maycontain too many or too few lines. Be sure to store the initial assignments in the tables.
a.int count = 11;
if (count > 12)
{count = 14;
}
else{count = 21;
}
b.int a = 4;
int b = 6;
if (a > b)
{a = a + 2;
}
else
{b = a + 1;
a = b + 1;}
if (a!=b)
{b = a+2;
}
c.int reward = 0; // Be careful about precedence in this part
double purchase = 122.80;
if (purchase < 25.0)
{reward = 0;}
else if (purchase < 50.0)
{reward = (int) purchase;}
else if (purchase < 100.0)
{reward = (int) purchase * 2;}
else{reward = (int) purchase * 3; }
d.int reward = 0;
double purchase = 122.80;
if (purchase > 25)
{reward = 0;}
else if (purchase > 50)
{reward = (int) purchase;}
else if (purchase > 100)
{reward = (int) purchase * 2;}
else {reward = (int) purchase * 3; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started