The converter in VB.NET: window, code and tests
Answers are for parents and teachers.
1
Trace the handler for the typed text 8 with Decimal ticked in From and Binary ticked in To. Give fromBase, toBase, number and the message.
fromBase 10, toBase 2, number 8, message 1000.
2
The user types 2B, with Hexadecimal in From and Decimal in To. What does the message box show? Show the working.
43, because 2 × 16 + 11 = 43.
3
The user types 5E, with Hexadecimal in From and Binary in To. Give the message and explain why it has seven digits.
1011110. 5 is 0101 and E is 1110, so the answer is 01011110, and the leading zero is not written.
4
A tester types 11 01, with a space in the middle, and ticks Binary in From. What happens in the plain converter and in the Try … Catch version?
The plain converter stops with an error, because a space is not a binary symbol; the Try … Catch version shows the polite message.
5
Which change to the last line makes the message show capitals? Write the line.
MessageBox.Show(Convert.ToString(number, toBase).ToUpper())