Directions: Use the following program segment:
IF Sex$ = "M" THEN
IF Height > 66 THEN
IF Weight > 180 THEN
PRINT "Try out for the football team."
END IF
END IF
END IF
Which of the following could replace this statement?
-
IF (Sex$ = "M") AND (Height > 66) AND (Weight >180) THEN
PRINT "Try out for football team."
END IF
-
IF (Sex$ = "M") OR (Height > 66) OR (Weight > 180) THEN
PRINT "Try out for football team."
END IF
-
IF (Sex$ = "M") AND (Height > 66) OR (Weight > 180) THEN
PRINT "Try out for football team."
END IF
-
IF (Sex$ = "M") AND NOT (Height > 66) AND (Weight > 180) THEN
PRINT "Try out for football team."
END IF
A
Correct answer
Explanation
The nested IFs require ALL conditions to be true: Sex$ = "M" AND Height > 66 AND Weight > 180. Only option A correctly uses AND to combine all three conditions.