Overall Requirements Write two programs encode.toy and decode.toy. Each TOY instruction must have corresponding pseudocode. (This is auto-generated by Visual X-Toy – see below.) It's also good practice to add line breaks between logically related "sections" of TOY code and write a comment above each "section" explaining what that code does. encode.toy Write a TOY program encode.toy
Overall Requirements
- Write two programs encode.toy and decode.toy.
- Each TOY instruction must have corresponding pseudocode. (This is auto-generated by Visual X-Toy – see below.) It's also good practice to add line breaks between logically related "sections" of TOY code and write a comment above each "section" explaining what that code does.
encode.toy
Write a TOY program encode.toy to encode a binary message using the scheme described above. Repeatedly read four (4) bits m1, m2, m3, m4 from TOY standard input and write the seven (7) bits m1, m2, m3, m4, p1, p2, p3 to TOY standard output. Stop upon reading FFFF from standard input.
- p1 = m1 ^ m2 ^ m4
- p2 = m1 ^ m3 ^ m4
- p3 = m2 ^ m3 ^ m4
Recall that ^ is the exclusive or operator in Java and TOY. This captures the parity concept described above.
decode.toy
Write a TOY program decode.toy to decode and correct a Hamming encoded message. Repeatedly read seven (7) bits m1, m2, m3, m4, p1, p2, p3 from TOY standard input and write the four (4) correct bits m1, m2, m3, m4 to TOY standard output. Stop upon reading FFFF from standard input. Recall, to determine which one, if any, of the message bits is corrupted, perform the parity checks:
- p1 = m1 ^ m2 ^ m4
- p2 = m1 ^ m3 ^ m4
- p3 = m2 ^ m3 ^ m4
Trending now
This is a popular solution!
Step by step
Solved in 2 steps