Write a program that reads a line of printable characters and encodes with a sequence of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that reads a line of printable characters and encodes with a sequence of keys with each key is a binary string of '0's and '1's. The sequence of keys starts with one key with length 1, followed by three keys with length 2, seven keys of length 3, fifteen keys of length 4, etc. The keys of the same length are in sequence of its binary value but not with all '1's. The encoding scheme is as follows. Assume the input header is: n(X+# $90\"? # $90\ ? 000 001 010 011 100 101 110 0000 n + key string: 0 00 01 10 11 To verify the correctness of the encoding, write a function to read in a character and print the key(s) of that character. Notes: 1. You may not know the length of the header in advance. 2. The maximum length of the key string is seven. That is, the longest key string is "1111110" Hint: A character string should have a "\0' at the end of the string. $ 010 *** Sample Input and Output Example 1 Enter Header: n(X+# $90\"? Enter character: 3. The header contains only printable characters including "space", i.e. any characters in the ASCII Table with values from 32 to 126. 4. We assume the input is valid, i.e., no need to check the correctness of input. 5. The header may have repeated characters that lead to different keys. Example 2 Enter Header: n(X+# $90\"?n Enter character: n 0 0001 Example 3 Enter Header: n(X+# $90\"? Enter character 001 input here is a "space" Write a program that reads a line of printable characters and encodes with a sequence of keys with each key is a binary string of '0's and '1's. The sequence of keys starts with one key with length 1, followed by three keys with length 2, seven keys of length 3, fifteen keys of length 4, etc. The keys of the same length are in sequence of its binary value but not with all '1's. The encoding scheme is as follows. Assume the input header is: n(X+# $90\"? # $90\ ? 000 001 010 011 100 101 110 0000 n + key string: 0 00 01 10 11 To verify the correctness of the encoding, write a function to read in a character and print the key(s) of that character. Notes: 1. You may not know the length of the header in advance. 2. The maximum length of the key string is seven. That is, the longest key string is "1111110" Hint: A character string should have a "\0' at the end of the string. $ 010 *** Sample Input and Output Example 1 Enter Header: n(X+# $90\"? Enter character: 3. The header contains only printable characters including "space", i.e. any characters in the ASCII Table with values from 32 to 126. 4. We assume the input is valid, i.e., no need to check the correctness of input. 5. The header may have repeated characters that lead to different keys. Example 2 Enter Header: n(X+# $90\"?n Enter character: n 0 0001 Example 3 Enter Header: n(X+# $90\"? Enter character 001 input here is a "space"
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Felinas Inc. produces floor mats for cars and trucks. The owner, Kenneth Felinas, asked you to assist him in estimating his maintenance costs. Together, Mr. Felinas and you determined that the single...
-
In Problem 11.4.5, we used simulation to estimate the probability of symbol error. For transmitting a binary bit stream over an MPSK system, we set each M = 2N and each transmitted symbol corresponds...
-
In this project, we will write a program that controls a quiz show, much like the many popular TV shows. The program will read in a group of questions and their multiple choice answers, storing them...
-
Clapton Company's sales budget shows the following projections for the year ending December 31, 2017: Quarters First (Jan -March) Second (April June) Third (July-Sept) Fourth (Oct-Dec) Total First...
-
In 1991, the frozen remains of a Neolithic-age man, nicknamed Otzi, were found in the Italian Alps by hikers. The body was well preserved, as were his bow, arrows, knife, axe, other tools, and...
-
HydroGen will issue a 30-year bond on 15 June 2021, paying coupon semi- annually at j2-2.6% p.a. Future payments of coupon and return of capital will depend on the viability of the business. You have...
-
What are information quality and environmental quality? Are they related? Why is low-quality information said to drive out high-quality information?
-
The income statements of Evans Company and Falcon Company for the current year are shown below: The following amounts were taken from the statement of changes in equity for the two companies: Evans...
-
(1) Purity Manufacturing Ltd. has been depreciating their building using straight line method over 50 years. The current carrying amount is $775,000 they use a residual value of $45,000, and there is...
-
The following data relates to Prism traders limited for the year ended 31st December, 2018. Shs Cash and marketable securities Fixed Assets Sales Net Income Quick Ratio Current Ratio Average...
-
Calculate the following values (1) A = C, + C2 where, C= add all digits of your Batch e.g. 2+0+1+6 - 9 (If you are from 2016 Batch) C2= add all digits of your Roll Number e.g. 0+4+9 = 13 (If your...
-
For the financial year ended 31 March 2020, the draft final accounts of Langsam Berhad and its subsidiary, Schnell Berhad are as follows: Statement of Profit and Loss for the year ended 31 March 2020...
-
Determine the financial effect on the balance sheet and income statement for each of the following independent events using the Transaction Analysis Template. a . Paid $ 4 , 0 0 0 for six months...
-
Unpolarized sunlight goes through two pairs of sunglasses. The second pair is oriented 20 o respect to the first. What is the exiting intensity in terms of the initial intensity I0?
-
A wheel initially at rest begins rotating because of a constant angular acceleration. During a certain interval AT = 13s, the wheel goes through 84 rev and reaches an angular speed of 11 rev/s. (a)...
-
The plant asset and accumulated depreciation accounts of Pell Corporation had the following balances at December 31, 2023: Land Land improvements Building Equipment Automobiles Plant Asset...
-
Given the following list of integration techniques: Integration by Parts Polynomial Long Division Trigonometric Substitution Explain which technique(s) can be used to evaluate the integrals below,...
-
Write the statement to store the contents of the txtAge control in an Integer variable named intAge.
-
Write a Java enumeration LetterGrade that represents letter grades A through F, including plus and minus grades. Define a private instance variable to hold a boolean value that is true if the grade...
-
Repeat the previous question, but use the comma operator and omit the for statements body.
-
Write a JavaFx application that displays a series of pictures of a person with arms, legs, and of course a head. Use a happy face for the head. Use ovals for the body, arms, and legs. Draw a sequence...
-
Discuss some of the special considerations involved in the audit of investments in group entities.
-
Joplin Ltds financial year ends on 30 June 20X1 and the companys auditor, Hagan and Partners, conducts the annual audit during July and August. Hagan and Partners has prepared auditing procedures for...
-
What is a solicitors representation letter? What effect might the failure of a solicitor to respond to a request for representation have on the auditors report?
Study smarter with the SolutionInn App