Q:

&& Syntax Error AGP for Dummies

So, I am currently learning off of the Android Game Programming For Dummies book, and have run into the problem where (On page 128) I'm given the code
case MotionEvent.ACTION_DOWN:
      if (X > (screenW-playButtonUp.getWidth())/2 &&
          X < ((screenW-playButtonUp.getWidth())/2) +
                    playButtonUp.getWidth()) &&
          Y > (int)(screenH*0.45) && 
          Y < (int)(screenH*0.45) +
          playButtonUp.getHeight()) {
              playButtonPressed = true;
          }
break;

and the 4th to 6th lines are accompanied by the error "Syntax error on token "&&", throw expected". I have no idea on how to fix this, I'd really appreciate any alternatives or help.

A:

The parentheses are messed up.  Specifically, the second ) in this line:
//                     -- This one
//                     v
playButtonUp.getWidth()) &&

matches the ( starting the if condition, meaning the && after it is not part of the condition.  Remove that extra ).
Here's a parentheses analysis:
if (X > (screenW-playButtonUp.getWidth())/2 &&   // ( = 3, ) = 2; Nested level: 1
    X < ((screenW-playButtonUp.getWidth())/2) +  // ( = 3, ) = 3; Nested level: 1
              playButtonUp.getWidth()) &&        // ( = 1, ) = 2; Nested level: 0
    Y > (int)(screenH*0.45) &&                   // ( = 2, ) = 2; Nested level: 0
    Y < (int)(screenH*0.45) +                    // ( = 2, ) = 2; Nested level: 0
    playButtonUp.getHeight()) {                  // ( = 1, ) = 2; Nested level: -1?!?
        playButtonPressed = true;                // Total ( = 12, ) = 13
    }

