- Enter a do-while loop and
generate a random, byte-sized, value in the range of 0 to 255. Store the random
value in a variable of type byte.
Display the value in hex as shown below.
- The user will input a string containing 1's and 0's. Use a
do-while loop to ensure that the length of the string is 8 characters; if it is
not, honk the speaker and display an error message in yellow, and obtain new
input. An invalid guess is not
counted as one of the five hex values. The hex value for which an incorrect
number of bit was entered will be repeated again, as shown below.
- Convert the string to a byte-sized
number. Compare the number with the random value. If the two values are the
same, display a message indicating a correct result and increment the number of
correct responses. If the values are different, display a message indicating
that the user's response was incorrect.
- Continue looping until the user
has been presented with five hex
values.
·
Display the number of correct
responses.
An example of the program being executed is
shown below. Use yellow to indicate error messages, and green to indicate
correct responses and the final results.
The random byte-sized value can be
generated using the random number generator. In the code shown below, the
random number generator is named rndGen, and the hex value is named byHex.
byHex
= (byte)rndGen.Next(256);
The user will input their binary value as a
string of 1's and 0's. The string (sInput) can be converted to a byte by the
following code:
byInput = Convert.ToByte(sInput, 2);
I have zero clue, what to do...help me pls...