Thursday, February 13, 2014

Section 4.1: Relational and Logical Operators - Boolean Variables




40109:  Write an expression that evaluates to true if and only if the value of the boolean variable workedOvertime is true.

workedOvertime

41059:  Assume that a bool variable isQuadrilateral has been declared, and that an int variable, numberOfSides has been declared and initialized.  Write a statement that assigns the value true if numberOfSides is exactly 4 and false otherwise.

If numberOfSides = 4 Then
isQuadrilateral = true
Else
isQuadrilateral = false
End if

41058:  Assume that a bool variable worked Overtime has been declared, and that an int variable hoursWorked has been declared and initialized.  Write a statement that assigns the value true if hoursWorked is greater than 40 and false otherwise.

If hoursWorked > 40 Then
workedOvertime = true
Else
workedOvertime = false
End if

40050:  Write a literal representing the true value.

true

40049:  Write a literal representing the false value.

false

No comments:

Post a Comment