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 nowThis is a popular solution!
Step by stepSolved in 2 steps
- the odd numbers are the numbers in the sequence 1,3,5,7,9, .... Define the sequence of S - numbers as follows: the first S - number is 1 The second S - number is the sum of the first S - number and the second odd number the third s - number is the sum of the second S- number and the third odd number. the fourth S- number is the sum of the third S- number and the fourth odd number, etc..,... compute the first seven S- numbers. make a note of any patterns you notice. enter the first seven S- numbers as a comma - seperated list: first seven S- numbers = ________________arrow_forwardAnswer in Python 3! Frequency analysis loop programarrow_forwardPython Coding:arrow_forward
- 1. Write pseudocode as in Algorithm 2(b) that convert the distance in mile to kilometre. Trace the content of the variables and determine the output. Algorithm 2(b): Convert distance mile to kilometre. Start Set kmPerMile to 1.609 Set distanceMile to 100 Convert distance in mile to kilometre using formula distanceInkilometre = kmPerMile x distanceMile Display output of distanceInKilometre Endarrow_forwardComputer sciencearrow_forwardpython please explain so i understandarrow_forward
- REPETITION CONTROL STRUCTURE (FOR) Instruction: Write a Java program that reads a positive, non-zero integer as input and checks if the integer is deficient, perfect, or abundant. A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors (i.e., the positive integers, other than N itself, that divide N exactly) is equal to the number itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than N, the number is said to be abundant. The first few perfect numbers are 6, 28, 496, and 8128. Illustrations: Number Factors of the number less than itself Sum of Factors 3, 2, 1 14, 7, 4, 2, 1 6 6 28 28 For example, the number 6 is perfect, since 6 = 1 + 2 + 3, the number 8 is deficient, since 8 >1 + 2 + 4, while the number 12 is abundant, since 12<1 + 2 + 3 + 4 + 6. Sample Input/Output: Depicted below are sample outputs when the program is executed (the items in bold characters are input from the user, while the items…arrow_forward2. Characters in Strings A large part of the text processing done by computers involves reading user input and figuring out what it means. We'll do something like that today: given a string supplied by a user, we report (1) the total length of the string, (2) how many alphabetic characters, (3) how many numeric characters, (4) how many vowels (a, e, i, o, u) were in that string, and (5) how many of the alphabetics were upper-case. For example, if a user input this line: the program would say: String length: 30 James Bond, 007, works for MI6 Alphabetics: 19, upper-case: 4 Numerics: 4 Vowels: 6 You will need to use a new (to us) function to read the user input. You have been using cin but this won't work for your needs in this program. Instead, use getline (cin,s) where s is a string variable. That string will contain everything the user typed up to but not including the Enter the user typed to end the line. So you have a string but you'll need a loop to check for each individual…arrow_forwardIn pseudocode Input in a number representing a car type, until the number 0 is input. There are three typesof cars: 1 = luxury, 2 = commercial, 3 = sedan. Count how many of each type there are andprint out this total with a message stating what type of car it is.arrow_forward
- Java program | nested looparrow_forwardPlease help me solve this problem C. Chess Boundary Positions: Write a program called chess_pos.py On a chessboard, positions are marked with letters between a and h for the column and a number between 1 and 8 for the row. Give a 2 character input string with a letter (a-h) and a number (1-8), print "Corner" if the value indicates a square on a corner. Print "Border" if the value indicates a square on an edge of the board. Otherwise, print "Inside".arrow_forwardExercise 1 Backward String Python Pleasearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education