CS 101 Notes 10/14/2010 We can combine multiple if statements into what is often called an "else-if" clause. if (yearCode == 1) { System.out.println ("Freshman"); } else if ( yearCode == 2) { System.out.println ("Sophomore"); } else if ( yearCode == 3) { System.out.println ("Junior"); } else if (yearCode == 4) { System.out.println ("Senior"); } else { System.out.println ("Unknown"); } Boolean Operators - AND &&, OR ||, NOT ! take values of TRUE and FALSE and compute a result that is either TRUE or FALSE AND - Binary operators (takes 2 operands) the result is TRUE if both operands are TRUE otherwise the result is FALSE if ((number >= 1) && (number <= 10)) OR - Binary operator (takes 2 operands) the result of TRUE if at least one operand is TRUE otherwise the result if FALSE if ((yearCode == 3) || (yearCOde ==4)) NOT - unary operator (takes 1 operand) the result if TRUE when the operand is FALSE otherwise the result is FALSE if (!(value == 10)) X Y " X && Y X || Y !X =============================== T T " T T F T F " F T F F T " F T T F F " F F T