Question: Imagine that variables roll1, roll2, and roll3 represent three die rolls (each storing a value between 1 and 6). Examine the following Boolean expressions, then
Imagine that variables roll1, roll2, and roll3 represent three die rolls (each storing a value between 1 and 6). Examine the following Boolean expressions, then describe in English the condition that each represents.
(roll1 == 1 && roll2 == 1)
((roll1 + roll2 == 11) || (roll1 + roll2 == 12))
(roll1 > 2 && roll1 < 5)
(roll3 < 3 || roll3 > 4)
(roll1 == roll2 && roll2 == roll3)
(roll1 == 1 && roll2 == 1 && roll3 == 1)
Does the following expression correctly represent the condition that all three die rolls are different? That is, does this expression evaluate to true if all three variables have unique values, but evaluate to false in all other cases? If you believe that the expression accurately represents this condition, justify your claim. If not, provide a correct expression that performs the task.
(roll1 != roll2 && roll2 != roll3)
Step by Step Solution
3.42 Rating (165 Votes )
There are 3 Steps involved in it
roll1 and roll2 are both 1s The sum of roll1 and roll2 is either 11 or 12 roll1 is between 2 and 5 ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
1409-C-S-O-S(1053).docx
120 KBs Word File
