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...
-
IAB conducted a study of U.S. online adults that included 416 tablet owners. The study found that 221 tablet owners use their tablet while watching TV. The authors of the report imply that the survey...
-
An external review should be relevant to the particular internal auditing department being evaluated. To that end, the first step in such a review is to compare the department's charter with the...
-
What should a credit analyst consider as the basic of credit risk?
-
A sample of 10 NCAA college basketball game scores provided the following data. a. Compute the mean and standard deviation for the points scored by the winning team. b. Assume that the points scored...
-
Plot the complex numbers -7+i and 3-6i in the complex plane. Im Re 8
-
The 2023 financial statements of Outdoor Waterworks Inc. follow: Assume all sales were on credit. Also assume the long-term note payable is due in 2026, with no current portion. On the December 31,...
-
The charter of Elleanor Corporation authorizes the issuance of 1,000 shares of preferred stock and 1,600 shares of common stock. During a two-month period, Elleanor Corporation completed these...
-
Suppose that a ball is dropped (V = 0) from a tower 70.0 m high. How far will it have fallen after a time t = 1.00 s, t = 2.00 s, and t3 = 3.00 s? Ignore air resistance. Acceleration due to gravity...
-
Michelle and Martin wanted to take advantage of a sale to buy a new television. The one they liked was worth $2,340, but a 25% discount was granted during the sale. After taking advantage of the...
-
On January 1, 2020, Borrowing Company Inc. has a $100,000 loan that charges a 10% interest rate each year. The company has agreed to make a $30,000 payment at the end of each year. 7. What will be...
-
While driving in his car ( m = 1 2 5 0 kg ) , Mr . Gaglardi runs out of gas at the bottom of an ice covered hill that slopes upward at an angle of 3 5 \ deg to the horizontal. Moments later, Ms ....
-
A snow insurance company offers an insurance contract that costs the buyer an upfront premium at the beginning of 2023. The contract specifies that if it snows more than 2 feet in CT on any single...
-
Essay Question 1. Compare Malaysia and India's political stability index 2. Describe briefly India's political and legal environments, and discuss how does it impact on global marketing in the...
-
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...
-
Dollar/Euro Forwards. Use the following spot and forward bid-ask rates for the U.S. dollar/euro (US$/) from December 10, 2010, to answer the following questions: a. What is the mid-rate for each...
-
Swissie Triangular Arbitrage. The following exchange rates are available to you. (You can buy or sell at the stated rates.) Assume you have an initial SF12,000,000. Can you make a profit via...
-
Aussie Dollar Forward. Use the following spot and forward bid-ask rates for the U.S. dollar/Australian dollar (US$ = A$1.00) exchange rate from December 10, 2010, to answer the following questions:...
Study smarter with the SolutionInn App