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)
- Write a function-based C++ program that reads an integer array from a file (“input.txt”) and finds all integers which start and end with the same digit. Write these integers into an output file (“output.txt”). You may assume the length of each integer to be a minimum of 2 digits. Example: Input File 12 131 54 7541 9849 6456 Output File 131 9849 6456arrow_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_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
- write a program that will open a file called “story.txt”and count the number of occurrences of each letter from the alphabet in this file.At the end your program will output the following report:Number of occurrences for the alphabets:a was used – times.b was used – times.c was used – times…. …and so, onAssume the file contains only lower-case letters and for simplicity just a singleparagraph. Your program should keep a counter associated with each letter of thealphabet (26 counters) [Hint: Use array]Your program should also print a histogram of characters count by addinga new function print Histogram (int counters []). This function receives thecounters from the previous task and instead of printing the number of times eachcharacter was used, prints a histogram of the counters. An example histogram forthree letters is shown below) [Hint: Use the extended asci character 254]:arrow_forwardWrite a program that reads words from a file (filename given as a string parameter) and prints the occurance of each word(case insensitive). And print the words in alphabetical order. For example, if the file contains text Love is free free is love then the function should print free:2 is:2 love:2 def count_word(filename): # YOUR CODE HERE raise NotImplementedError()arrow_forwardWrite a program to compute the frequency of all words in a file. The output should show after sorting the words. Suppose the folowing are the content of file: New to Python ar choosing between Pythan 2 and Python 3? Read Python 2 or Pythan 3. Then, the output should be: 22 3.:1 37:1 New:1 Python:5 Read:1 and:1 between:1 choosing:1 or2 to:1arrow_forward
- Write a program that receives a coded message file(Lab3ExtraCreditCT.txt) from your local espionage agent and decodes it into a file using standard English. The problem is your agent forgot to tell you the key used to decode the message. Fortunately, this is a simple substitution code consistently using 1 alphanumeric character to represent another, this is case sensitive. All other characters are not substituted, so a space will always be a space, a – will always be a –, a @ will always be a @, etcetera. You may use the following table to help you, it contains the most common letters used in the English language in descending order. E A R I O T N S L C U D P M H G B F Y W K V X Z J Q 0 5 3 2 4 6 8 1 9 7 Using the following key to convert plaintext to coded text: Plaintext = Now is the time for all good men to come to the aid of their country. Key = THEQUICKBROWNFXJMPSVLAZYDG The file your program outputs should look like this: Coded Text = Fxz bs vku vbnu ixp tww…arrow_forwardWrite a program to handle a user's rolodex entries. (A rolodex is a system with tagged cards each representing a contact. It would contain a name, address, and phone number. In this day and age, it would probably have an email address as well.) Typical operations people want to do to a rolodex entry are: 1) Add entry 2) Edit entry 3) Delete entry 4) Find entry 5) Print all entries 6) Quit You can decide what the maximum number of rolodex entries is and how long each part of an entry is (name, address, etc.). When they choose to edit an entry, give them the option of selecting from the current rolodex entries or returning to the main menu — don't force them to edit someone just because they chose that option. Similarly for deleting an entry. Also don't forget that when deleting an entry, you must move all following entries down to fill in the gap. If they want to add an entry and the rolodex is full, offer them the choice to return to the main menu or select a person to overwrite. When…arrow_forwardplease use spyderarrow_forward
- Write a Python program that reads each line of an input file workshop.txt that consists of a city name followed by a climate conditions like ( temperature, Humidity, Wind). The program will then decide whether it's possible to conduct a workshop in the city or not depending on the following conditions in sequence: • If temperature >20 and Humidity is not low then it's possible to conduct a workshop. If wind is normal and temperature is greater than 30 then it's possible to conduct a workshop. Save the results in a file called results.txt. For example, if the workshop.txt contains Muscat: 25, high, strong Suhar: 20, high normal Salalah: 15, low, normal The file results.xt. will contain Muscat: yes Suhar: no Salalah: noarrow_forwardUsing a csv file attached (https://file.io/NMvbdnv4E3r0), Create a program on python that use the csv file. The program should accept a user's input of a compound. It should output the molar mass (in 2 decimal places only) of the compound.by using the csv file to compute for the atomic mass at name of the elements. Furthermore, if the "elements involved" are wrong an invallid message should be outputted and only existing chemical symbols are the output. The same goes for wrong input of the "number of atoms" wherein a wrong an invallid message should be outputted and only integers are to be inputted by the user. Program should look like this: Enter compound: C6H12O6 Enter elements involved: C,H,O Enter no. of Carbon atoms: AA Enter no. of Hydrogen atoms: 12 Enter no. of Oxygen atoms: 6 Wrong input of number of atoms! Try again. or Enter compound: C6H12O6 Enter elements involved: C,H,O Enter no. of Carbon atoms: 6 Enter no. of Hydrogen atoms: 12 Enter no. of Oxygen atoms: 6…arrow_forwardWrite a java program to perform statistical analysis of scores for a class of students. The class may have up to 40 students.There are five quizzes during the term. Each student is identified by a four-digit student ID number. The program is to print the student scores and calculate and print the statistics for each quiz. The output is in the same order as the input; no sorting is needed. The input is to be read from a text file. The output from the program should be similar to the following: Here is some sample data (not to be used) for calculations: Stud Q1 Q2 Q3 Q4 Q5 1234 78 83 87 91 86 2134 67 77 84 82 79 1852 77 89 93 87 71 High Score 78 89 93 91 86 Low Score 67 77 84 82 71 Average 73.4 83.0 88.2 86.6 78.6 The program should print the lowest and highest scores for each quiz. Plan of Attack Learning Objectives You will apply the following topics in this assignment: File Input operations. Working and populating an array of objects. Wrapper Classes. Object…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning