Suppose that a binary file contains exactly three numbers written to the file using the method writeDouble of the class ObjectOutputStream. Suppose further that you write a
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
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Concepts Of Programming Languages
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Degarmo's Materials And Processes In Manufacturing
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- consider a program that reads data from a text file called: "klingon-english.txt" (shown below). How would one construct such a program with the following conditions: 1. Ask the user to choose a Klingon consonant they want to practice with. Ask again if the user’s answer is not a valid Klingon consonant, until the user enters a valid consonant. 2. Find a Klingon word that starts with the chosen consonant (the text file contains only one word that starts with any given consonant, so you don’t need to use the random library) 3. Ask the user to translate the chosen word into Klingon 4. Print "Correct" if the user’s answer is correct 5. Print "Sorry, you’re wrong!" if the user’s answer is wrong 6. Print The correct answer is ... if all three user’s answers are wrong You will also factor in this version: 7. If the answer is incorrect, show the first hint: the first and last characters of the correct Klingon word. When showing a hint, replace all other characters with a star (*) 8. If the…arrow_forwardWhen texting or tweeting, it’s not uncommon to shorten words to save time or space, as by omitting vowels, much like Twitter was originally called twttr. In a file called twttr.py, implement a program that prompts the user for a str of text and then outputs that same text but with all vowels (A, E, I, O, and U) omitted, whether inputted in uppercase or lowercase. USE PYTHON PLEASE SEE IMAGE FOR MORE DETAILS. THANKS.arrow_forwardwrite a program with python that asks the user to enter two filenames. One filecontains a list of words that you want to count. For the following explanation, let’s call it words.txt.(When your program runs, the user could type a different name. Do not hardcode any filenames inyour code.) The second file contains the text that you want to search for each word. For theexplanation, let’s call it story.txt.Ask the user to enter the name of each file. Assume that the files are located in the same directoryas your code file.For each word in words.txt, search through story.txt and count how many times the word occurs.Print a summary similar to the sample output below.Note 1: You should consider a “word” to be anything bounded by whitespace. You do not need todo any processing to account for punctuation or other special characters. For example, in thesample below, “time.” (with a period) is not considered the same as the word “time” (without aperiod). Capitalization will also matter. “The”…arrow_forward
- Write a Java program that reads in a paragraph of text from a file and prompts the user to enter a word to search for. The program should then output the number of times the word appears in the paragraph. Here are the basic steps to implement this program: Prompt the user to enter the name of the input file. Read in the paragraph of text from the input file. Prompt the user to enter a word to search for. Search the paragraph for the word and count the number of times it appears. Output the number of times the word appears in the paragraph. To implement step 4, you can use a similar approach to the example I provided in class: Split the paragraph into an array of words using the split() method. Iterate through each word in the array and compare it to the search word (ignoring case). If the word matches the search word, increment a counter variable.arrow_forwardWrite a complete program that uses an ifstream object to read integers from a file called numbers.txt, and an ofstream object to write into a file called evens.txt.Your program should have loop that reads each integer from the input file, then writes it into the output file if it is an even number. Write each even number in na separate line.Make sure to close both files before your program terminates.arrow_forwardSuppose that a binary file contains exactly three numbers written to the file using the method writeDouble of the class ObjectOutputStream. Suppose further that you write a program to read all three numbers using three invocations of the method readDouble of the class ObjectInputStream. If your program invokes readDouble a fourth time, what will happen?arrow_forward
- in java' Variables fStream and dataFS are FileInputStream and Scanner, respectively. String fileName is assigned a file's name read from input. Perform the following tasks: Assign fStream with a FileInputStream that opens the file fileName for reading. Assign dataFS with a Scanner created using fStream. Click here for example Ex: If the input is peach2.txt and: Data in file peach2.txt 4.3 then the output is: 4.3 GroceryDataProcessor.java peach1.txt peach2.txt peach3.txt public class GroceryDataProcessor { publicstaticvoidmain(String[] args) throwsIOException { Scannerscnr=newScanner(System.in); StringfileName; doublepeachWeight; FileInputStreamfStream=null; ScannerdataFS=null; fileName=scnr.next(); /* Your code goes here */ peachWeight=dataFS.nextDouble(); System.out.println(peachWeight); fStream.close(); } }arrow_forwardWrite an address book program that stores your contacts' names and their email addresses. The names and email addresses are originally stored in a file called phonebook.in, in the format: Harry Pottertheboywholived@hogwarts.eduHermione Grangerbrightestwitch@hogwarts.eduRon Weasleyroonilwazlib@hogwarts.eduDraco Malfoymyfatherwillhearaboutthis@hogwarts.eduSeverus Snapehalfbloodprince@hogwarts.eduAlbus Dumbledorealasearwax@hogwarts.edu Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item: 1) look up an email address2) add a new name and email address3) change an email address4) delete a name and email address5) save address book and exit When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry…arrow_forwardWrite a program that reads two input files whose lines are ordered by a key data field. Your program should merge these two files, writing an output file that contains all lines from both files ordered by the same key field. As an example, if two input files contain student names and grades for a particular class ordered by name (the key field), merge the information as shown below. File 1 and file 2 are supplied. Here is an algorithm to merge the data from two files: Read a line from each data file While the end of both files has not been reached While the end of both files has not been reached Write the line from file 1 to the output file and read a new line from file 1. Else Write the line from file 2 to the output file and read a new line from file 2. Write the remaining lines (if any) from file 1 to the output file. Write the remaining lines (if any) from file 2 to the output file. See the Merging Filesslides attachedto the project in Canvasfor a visual look at this algorithm.arrow_forward
- Create a program that reads a text file containing a 15 x 15 grid which represents a block of human cells and find the number of blobs of cancerous cells in the grid. The cells are depicted with a plus sign + if they are healthy, and a minus sign - if they are cancerous. Use the Flood Fill algorithm to determine the number of blobs. The program must be in Java language.arrow_forwardSuppose you have Java source files under the directorieschapter1, chapter2, . . . , chapter34. Write a program to remove the statement package chapteri; in the first line for each Java source file underthe directory chapteri. Suppose chapter1, chapter2,. . . , chapter34are under the root directory srcRootDirectory.The root directoryandchapteridirectory may contain other folders and files. Use the followingcommand to run the program:java Exercise12_20 srcRootDirectoryarrow_forwardWrite a program that reads a file containing two columns of floating-point numbers Prompt the user of the file name.Print the average of each column. javaarrow_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