Suppose that we want to store digitized audio information in a binary file. An audio signal typically does not change much from one sample to the next. In this case, less memory is used if we record the change in the data values instead of the actual data values.
We will use this idea in the following
Write a program StoreSignal that will read positive integers, each of which must be within 127 of the previous integer, from the keyboard (or from a text file, if you prefer). Write the first integer to a binary file. For each subsequent integer, compute the difference between it and the integer before it, cast the difference to a byte, and write the result to the binary file. When a negative integer is encountered, stop writing the file.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Database Concepts (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- You have been tasked to write a C++ program that will go through the first step of encrypting an input file and writing the encrypted contents to an output file.For each letter read in from the input file, add 3 letters to the value of the input letter. If the input letter is an A then the encrypted letter would be a D. If the input letter from the input file is an X then the encrypted letter would be an A. All spaces, digits, punctuation, and special characters do not need to be encrypted at this level. Simply write the space, punctuation, or special character to the output file as is. If a letter is uppercase in the input file, it should remain as an uppercase character in the output file. If a letter is lowercase in the input file, it should remain as a lowercase character in the output file.Since this program runs each month, the input file will be of various lengths; therefore, the program will read until end of file.The input file is found in the current directory and is…arrow_forwardWrite a word-wrapping program ww that reads the contents of a file and prints it to standard output, wrapped to fit within a specified width. For example, to reformat “text.txt” to fit in 80 columns: $ ./ww 80 text.txtarrow_forwardWrite a program that will sequentially list numbers from 0 to 50, changing its color depending on the size of the number, for example, for numbers from 0 to 10 it will be green, 11 to 22 red and 23 to 35 blue, etc. Limit the screen output speed to about 1 character / second. In order to change colors, you must first use the GetStdHandle function to get a handle to the console, which is similar to getting a file pointer before working with a file. It is done e.g. as follows: HANDLE hConsole; hConsole = GetStdHandle (STD_OUTPUT_HANDLE); The above functions are defined in windows.h Tip 2: Write a utility to find out the colors corresponding to all combinations from 0 to 255. Tip 3: Instructions and sample program for working with time. C language plz with explanation of codes. thanksarrow_forward
- Suppose you are given a text file that contains the names of people. Every name in the file consists of a first name and last name. Unfortunately, the programmer that created the file of names did not guarantee that each name was on a single line of the file. Read this file of names and write them to a new text file sorted according to first name, one name per line. For example, if the input file contains Ed Marston Bob Jones Jeff Williams Fred Charles The output file should be Bob Jones Ed Marston Fred Charles Jeff Williams Use arrays to solve the problem.arrow_forwardModify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file. Create an input file with your original three-or-more items and add at least three new items, for a total of at least six items. Include the following in your Learning Journal submission: The input file for your original dictionary (with at least six items). The Python program to read from a file, invert the dictionary, and write to a different file. The output file for your inverted dictionary. A description of how you chose to encode the original dictionary and the inverted dictionary in text files. Show more... Modify your program from Learning Journal Unit 7 to read dictionary items from a…arrow_forwardWrite a Python program to combine each line from the first file with the corresponding line in the second file and then save it in a 3rd file. Consider, both the files have same number of lines. Assume, each line has a newline(\n) at the end. ========================================================= Example:Input from file 1:HelloHiNice Input from file 2:BadWorseWorst Output in 3rd FIle:Hello BadHi WorseNice Worst ========================================================= Hint(1):Use the write() function what will be the answer of this in python programming languagearrow_forward
- Write a program that generates 10 random doubles, all between 1 and 11, and writes them to a text file, one number per line. Then write another program that reads the text file and displays all the doubles and their sum accurate to two decimal places.SAMPLE OUTPUT 10.6269119604172 2.737790338909455 5.427925738865128 1.3742058065472509 1.1858700262498836 4.180391276485228 4.910969998930675 5.710858234343958 7.790857007373052 3.1806714736219543 The total is 47.13arrow_forwardWrite a program to read several lines from a file. For each line, check (recursively) whether it is a palindrome. If it is a palindrome output the original string preceded by an integer (a counter) , like this: 1 : Sore was I, ere I saw Eros.2 : A man, a plan, a canal -- Panama Recall that a palindrome is a String that is the same backwards and forwards. Some examples of single words that are palindromes are: level, madam, racecar Phrases can also be palindromes if you strip out all the whitespace and punctuation and make everything the same case. Some examples are: Madam, I'm Adam A Toyota's a Toyota (See the palindrome video for more) You will need one method to eliminate whitespace and punctuation , make everything lowercase, and return the new string. Use the recursive method you wrote in L15Num2. This returns a string with no whitespace or punctuation, but not all the same case. Then (in main) convert that string to lowercase. You need a recursive method that takes the new…arrow_forwardPlease answer it in Python In the game of scrabble, each letter is associated with a number of points. It is these points that make it possible to calculate the score of each player at the end of the game. We would like our program to be able to choose, among the words we can play, the one with the highest total of points. To do this, we store the points corresponding to each letter in a text file called points.txt. Each line in this file contains a letter and its number of points, separated by spaces. Points.txt= https://tinyurl.com/pointtxt Download the points file.txt to your working directory. Write a function score_mot (points, word) that takes as an argument a dictionary matching each letter its number of points, and a word, and that returns the score. For example: What letters do you have in hand ? SALUT #return => Here's the best word you can play: SALUT for a score of: 5arrow_forward
- Suppose a library is processing an input file containing the titles of books in order to identify duplicates. Write a program that reads all of the titles from an input file called bookTitles.inp and writes them to an output file called duplicateTitles.out. When complete, the output file should contain all titles that are duplicated in the input file. Note that the duplicate titles should be written once, even though the input file may contain same titles multiple times. If there are not duplicate titles in the input file, the output file should be empty. Create the input file using Notepad or another text editor, with one title per line. Make sure you have a number of duplicates, including some with three or more copies.arrow_forwardPlease answer it in Python In the game of scrabble, each letter is associated with a number of points. It is these points that make it possible to calculate the score of each player at the end of the game. We would like our program to be able to choose, among the words we can play, the one with the highest total of points. To do this, we store the points corresponding to each letter in a text file called points.txt. Each line in this file contains a letter and its number of points, separated by spaces. Points.txt= https://tinyurl.com/pointstxt 1. Download the points file.txt to your working directory. 2. Write a function read_points() that reads the points file.txt and returns a dictionary that matches each letter to its number of dots (integer). 3. Write a function score_mot (points, word) that takes as an argument a dictionary matching each letter its number of points, and a word, and that returns the score. For example: What letters do you have in hand ? taslu #return => Here's…arrow_forwardSuppose a library is processing an input file containing the titles of books in order to identify duplicates. Write a program that reads all of the titles from an input file called bookTitles.inp and writes them to an output file called duplicateTitles.out. When complete, the output file should contain all titles that are duplicated in the input file. Note that the duplicate titles should be written once, even though the input file may contain same titles multiple times. If there are not duplicate titles in the input file, the output file should be empty. Create the input file using Notepad or another text editor, with one title per line. Make sure you have a number of duplicates, including some with three or more copies. (Programming Language: Java)arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT