We start with this and we compile, run and test it: 

public class LabThree {
  public static void main(String[] args) {
    int x = (int)(Math.random() * 6 + 1); 
    // x is now one of {1, 2, 3, 4, 5, 6}
    System.out.println( "We're working with: " + x ); 
    if (x % 2 == 1) { // x is odd 
      if (x <= 3) { // x is one of {1, 3}
        System.out.println( " x is 1 or 3 " ); // [1] 
      } else { // x is odd that is not <= 3
        System.out.println( " x is 5 " );  
      }
    } else { // x is even 
      System.out.println( " x is one of {2, 4, 6} " ); // [2] 
    }
  } 
}

Next we modify it: 

public class LabThree {
  public static void main(String[] args) {
    int x = (int)(Math.random() * 6 + 1); 
    System.out.println( "We're working with: " + x ); 
    if (x % 2 == 1) { 
      if (x <= 3) { 
        System.out.println( " x is 1 or 3 " ); 
      } 
    } else { 
      System.out.println( " x is one of {2, 4, 6} " ); 
    }
  } 
}

We then remove all curly braces: 

public class LabThree {
  public static void main(String[] args) {
    int x = (int)(Math.random() * 6 + 1); 
    System.out.println( "We're working with: " + x ); 
    if (x % 2 == 1)  
      if (x <= 3)
        System.out.println( " x is 1 or 3 " ); 
      else 
        System.out.println( " x is 5 " ); 
  } 
}

For the program to continue to be accurate we had to change the second print statement. 

Well known problem: the dangling else problem. 

Page: 104

  2 + 3 * 5 unambiguously can be written as (2 + (3 * 5))

Let's do the same with {'s and if statements: 

public class LabThree {
  public static void main(String[] args) {
    int x = (int)(Math.random() * 6 + 1); 
    System.out.println( "We're working with: " + x ); 
    if (x % 2 == 1) {
      if (x <= 3) { 
        System.out.println( " x is 1 or 3 " ); 
      } else {
        System.out.println( " x is 5 " ); 
      } 
    } else { 

    } 
  } 
}

That's what we have now when all the {'s have been deleted. 

--