Problem

What’s the Output?Determine the output of the following rather complicated Java fragment f...

What’s the Output?

Determine the output of the following rather complicated Java fragment for each of the declarations (a) through (j).

  if (a > b)  {    b++;    if (b > c)      c++;    if (y == x)      y++;    else z ++;    if (!m)    {      System.out.println("You may find yourself ");      System.out.println("Living in a shotgun shack ");      System.out.println(a + b);      System.out.println(y + a);    }    else    {      System.out.println("You may ask yourself ");      System.out.println("Well - How did I get here? ");      System.out.println(a + b);      System.out.println(x + y);    }  }  else  {    a = b + c;    if (x ! = 0)      x = y + z;    if (a ! = c)      c = c − 1;    else      c = c + 1;    if (c == 5)      System.out.println("Same as it ever was " + a);    else if (c == 6)      System.out.println("Same as it ever was " + b);    else if (c == 7)      System.out.println("Same as it ever was " + c);    else      System.out.println("Same as it ever was " + x);    }

a.  int a = 2, b = 4, c = 7; double x = 2.0, y = 3.14, z = -7.0; boolean m = true;b.  int a = 7, b = 1, c = 5; double x = 2.0, y = 2.0, z = 4.5; boolean m = false;c.  int a = 8, b = 2, c = 6; double x = 0.0, y = 0.0, z = 2.5; boolean m = true;d.  int a = 7, b = 3, c = 4; double x = 12.1, y = 1.2, z = 2.8; boolean m = false;e.  int a = 3, b = 9; c = 2; double x = 4.0, y = 4.0, z = 1.5; boolean m = false;f.  int a = 2, b = 7, c = 1; double x = 2.7, y = 2.7, z = 1.1; boolean m = true;g.  int a = 9, b = 9, c = 9; double x = 9.0, y = 9.0, z = 0.0; boolean m = false;h.  int a = -3, b = -3, c = 0; double x = 1.1, y = 1.2, z = 1.3; boolean m = true;i.  int a = 5, b = 2, c = 8; double x = 0.0, y = 0.0, z = -2.5; boolean m = false;j.  int a = 0, b = 1, c = 1; double x = 1.5, y = 2.5, z = 1.0; boolean m = false;

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT