Exercise Code for the Rule Demo in Java.