Review and your own mini-project
Answers are for parents and teachers.
1
Convert decimal 44 to binary and decimal 255 to hexadecimal, and check one answer by going back.
44 is 101100 (32 + 8 + 4 = 44). 255 is FF (15 × 16 + 15 = 255).
2
Convert hexadecimal 7A3 to decimal.
7 × 256 + 10 × 16 + 3 = 1,792 + 160 + 3 = 1,955.
3
A trace shows: start Off, Off, unlit; click A gives On, Off, lit; click B gives On, On, lit; click A gives Off, On, lit; click B gives Off, Off, unlit. Which gate does the simulator imitate?
OR: the lamp is unlit only when both texts are Off.
4
Write a PHP function f(bool $a, bool $b, bool $c): bool for L = A·B + ¬C and say what f(true, true, false) returns.
return ($a && $b) || !$c; and f(true, true, false) returns true.
5
Say in one sentence what the lamp program should do for a missing or wrong input, and why.
It should report invalid input and not change the lamp, because a guessed value could light or switch off the lamp wrongly.