Homework 5 Section #2 1. (5.1) If two or more values are equal then min will be set equal to num3 and that value will be printed out. In some cases it does matter if the two equal values are less or higher than the third. For example, if num2 and num3 are equal and they are both greater than num1 then the first condition will hold and the second condition will also hold true and min will be assigned to num1. (5.2) The if-then-else problem of parsing. The else matches the second if statement i.e. if (total < sum). This means, the print statement will be incorrect, when total is equal to MAX but greater than or equal to sum. For the output to be correct, the else statement should match the first if condition and not the second. Correct code fragment is as follows if (total == MAX) { if ( total < sum ) System.out.println("total == MAX and is < sum"); } else System.out.println("total is not equal to MAX"); Note: The typographical error in the first println statement is not the error. Please check the text book. (5.3) if (length = MIN_LENGTH) System.out.println("The length is minimal."); The condition in the if statement is not a comparision, but rather an assignment. If both length and MIN_LENGTH are of type integer or any numeric type then there will be compile error and will not compile. However, if both length and MIN_LENGTH are of type "boolean", then there will be no error as the value of the expression is also a boolean, which is the same type as a comparision. (5.4) apple orange pear (5.5) lime grape