Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10.4, Problem 23STQ
Does the class FileInputStream have a method named readInt? Does it have one named readDouble? Does it have one named readUTF?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In Java
Suppose you are given a text file that contains the names of people. Every name in the file consistsof a first name and a last name. Unfortunately, the programmer that created the file of names hada strange sense of humor and did not guarantee that each name was on a single line of the file.Write a program that reads this file of names and writes them to a new text file, one name per line.For example, if the input file (Names.txt) contains:Bob Jones FredCharles EdMarstonJeffWilliamsThe output file (RecoveredName.txt) should be:Bob JonesFred CharlesEd MarstonJeff WilliamsSample Output:Enter the name of the input file:Names.txtEnter the name of the output file: RecoveredName.txtFile processing completed.
In Java
Suppose you are given a text file that contains the names of people. Every name inthe file consists of a first name and a last name. Unfortunately, the programmer thatcreated the file of names had a strange sense of humor and did not guarantee thateach name was on a single line of the file. Write a program that reads this file ofnames and writes them to the console, one name per line.For example, if the input file (Names.txt) contains:Bob Jones FredCharles EdMarstonJeffWilliamsThe output should be:Bob JonesFred CharlesEd MarstonJeff Williams
Sample Output:Enter the name of the input file:Names.txtBob JonesFred CharlesEd MarstonJeff WilliamsFile processing completed.
Implement (in Java) a console application for writing data to a sequential text file with a formatter class in Java :
a. Implement createFile() method – To open/create a new file named as ‘mec.txt’ with explanations of the methods involved.
b. Implement writeRecord() method – User enter the employee name, employee id, gross salary, tax rate, income tax and net salary from the keyboard and write/add these values to the file ‘mec.txt’ with explanations of the methods involved. The input fields must be validated as necessary.
c. Implement closeFile() method – Close the file with explanations of the methods involved.
Chapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 10.1 - Why would anybody write a program that sends its...Ch. 10.1 - When we discuss input, are we referring to data...Ch. 10.1 - What is the difference between a text file and a...Ch. 10.2 - Write some code that will create a stream named...Ch. 10.2 - Prob. 5STQCh. 10.2 - Prob. 6STQCh. 10.2 - Prob. 7STQCh. 10.2 - Write some code that will create a stream named...Ch. 10.2 - Suppose you run a program that writes to the text...Ch. 10.2 - Prob. 10STQ
Ch. 10.3 - Prob. 11STQCh. 10.4 - Write some Java code to create an output stream of...Ch. 10.4 - Give three statements that will write the values...Ch. 10.4 - Give a statement that will close the stream toFile...Ch. 10.4 - What import statement(s) do you use when creating...Ch. 10.4 - Prob. 16STQCh. 10.4 - Give three statements that will read three numbers...Ch. 10.4 - Give a statement that will close the stream...Ch. 10.4 - Can you use writeInt to write a number to a file...Ch. 10.4 - Can you use readUTF to read a string from a text...Ch. 10.4 - Prob. 21STQCh. 10.4 - Prob. 22STQCh. 10.4 - Does the class FileInputStream have a method named...Ch. 10.4 - Does the class FileOutputStream have a constructor...Ch. 10.4 - Does the class ObjectOutputStream have a...Ch. 10.4 - Prob. 26STQCh. 10.4 - Suppose that a binary file contains exactly three...Ch. 10.4 - The following code appears in the program in...Ch. 10.4 - Prob. 29STQCh. 10.5 - Prob. 30STQCh. 10.5 - Prob. 31STQCh. 10.5 - Prob. 32STQCh. 10.5 - Prob. 33STQCh. 10.6 - Prob. 34STQCh. 10.6 - Prob. 35STQCh. 10 - Write a program that will write the Gettysburg...Ch. 10 - Modify the program in the previous exercise so...Ch. 10 - Write some code that asks the user to enter either...Ch. 10 - Write a program that will record the purchases...Ch. 10 - Modify the class LapTimer, as described in...Ch. 10 - Write a class TelephoneNumber that will hold a...Ch. 10 - Write a class contactInfo to store contact...Ch. 10 - Write a program that reads every line in a text...Ch. 10 - Repeat the previous exercise, but write the new...Ch. 10 - Write a program that will make a copy of a text...Ch. 10 - Suppose you are given a text file that contains...Ch. 10 - Suppose that you have a binary file that contains...Ch. 10 - Suppose that we want to store digitized audio...Ch. 10 - Write a program RecoverSignal that will read the...Ch. 10 - Even though a binary file is not a text file, it...Ch. 10 - Write a program that searches a file of numbers...Ch. 10 - Write a program that reads a file of numbers of...Ch. 10 - The following is an old word puzzle: Name a common...Ch. 10 - The Social Security Administration maintains an...Ch. 10 - The following is a list of scores for a game....Ch. 10 - Write a program that checks a text file for...Ch. 10 - Prob. 5PPCh. 10 - Prob. 6PPCh. 10 - Revise the class Pet, as shown in Listing 6.1 of...Ch. 10 - Write a program that reads records of type Pet...Ch. 10 - Prob. 12PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (8th Edition)
Write an import statement that makes the Scanner class available to your program or other class.
Absolute Java (6th Edition)
True or False: A class may only implement one interface.
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
A program will fall through to the following case section if it is missing the _____ statement.
Starting Out with C++: Early Objects
Which of the following are correct? a. False |= True. b. True |= False. c. (A B) |= (A B). d. A B |= A B. e...
Artificial Intelligence: A Modern Approach
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a program that reads a list of enrollments from a file and prints a class roster for the teacher. Make the class roster line up as neatly as you can and still fit on the screen. You can choose the actual values to use for your data. Make sure to do enough sets of data to well test your program! (Empty data set, normal data set, data with large values, data with short values, etc.) Also, your program can't know ahead of time how many people are enrolled in the class... Don't forget to read the file's name from the user and protect your program against any errors that may occur during the opening of the file. Try to use functions to break up the program into more manageable pieces. USING C++ As an example, you might have the data file contain:arrow_forwardWrite a Java program that allows the user to specify a file name on the command line and prints the number of characters, words, lines, average number of words per line, and average number of characters per word in that file. If the user does not specify any file name, then prompt the user for the name.arrow_forwardWrite a program that reads a list of enrollments from a file and prints a class roster for the teacher. Make the class roster lineup as neatly as you can and still fit on the screen.You can choose the actual values to use for your data. Make sure to do enough sets of data to well test your program!(Empty data set, normal data set, data with large values, data with short values, etc.)Also, your program can't know ahead of time how many people are enrolled in the class... using c++arrow_forward
- Develop a program that will do the following using Java and Javaclasses of Filewriter and Arraylist: The program has the interface[A] Add[D] Delete[U] Update[S] Search[X] Exit Select Operation: A You are about to add a user. Enter the First name:Enter the Last name:Enter the username:Enter password: The user has been successfully added. Do you wish to do another operation? [Y/N]: Y ---------------------------------------------------------------------------------------------- [A] Add[U] Update[S] Search[D] Delete[X] Exit Select Operation: U You are about to update user information. Search ID: 3 User information:First name: GeraldLast name: MorenoUsername: igeraldPassword: egerald Enter new username: asxsEnter new password: erdasdfr Username and Password have been updated successfully. Do you wish to do another operation? [Y/N]: Y ---------------------------------------------------------------------------------------------------------- [A] Add[U] Update[S] Search[D] Delete[X] Exit Select…arrow_forwardJava question: A text file called names.txt contains one name per line, e.g.,AllisonJohnWilliamJohnetc.Names can be duplicated in the file. Write the code that:1. Reads the names line by line.2. Stores each name and the number of times the name appears in one collection.3. Prints the number of different names to the console.4. Prints the names and how many times each name appears on the console.Think about what data structure would work in associating each name with the number of times it appears in the file. You do not need to write imports.arrow_forwardWrite a program that will read the file text.txt which is provided and the encryptedmessage in there. Please write back the decrypted message into the output.txt file.When you see the message in the output.txt file, you need to submit the java codefile. You need to use Rot13 class for decrypting the message. Do not need to submit in the output.txt file. file example: public class FileExample { public static void main(String[]args){ try {//create file object for input.txtFile in_file = new File("src/input.txt");//create file object for output.txtFile out_file = new File("src/output.txt"); //read the input.txt file with ScannerScanner read = new Scanner(in_file);//write the output.txt file with PrintWriterPrintWriter w = new PrintWriter(out_file); while(read.hasNextLine()){w.write(read.nextLine());} //don't forget to closew.close(); // while(scan.hasNext()){// System.out.println(scan.next());// } }catch(Exception ex){ex.getStackTrace();}arrow_forward
- Add a method called save to your Person class. This method will write the object out to a binary file. Use the Serializeable format. Name the file accountNumber.dat where accountNumber is the credit card number from the object. Code in Java /////////////////FIles given (Demo.java) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\import java.util.ArrayList;import java.util.Collections;public class Demo {public static void main(String[] args) {Person test1 = new Person("Eachelle Balderstone",30526110612015L,9866.30,false);Person test2 = new Person("Brand Hallam",3573877643495486L,9985.21,false);Person test3 = new Person("Tiphanie Oland",5100172198301454L,9315.15,true);ArrayList<Person> list = new ArrayList<>();list.add(test1);list.add(test2);list.add(test3);Collections.sort(list);System.out.printf("%20s%20s%10s%10s\n", "Name", "Account Number", "Balance", "Cash Back");for (Person current : list) {System.out.println(current);}}}arrow_forwardPlease use JAVA code to write the solution, thanks A text file called names.txt contains one name per line, e.g.,AllisonJohnWilliamJohnetc.Names can be duplicated in the file. Write the code that:1. Reads the names line by line.2. Stores each name and the number of times the name appears in one collection.3. Prints the number of different names to the console.4. Prints the names and how many times each name appears on the console.Think about what data structure would work in associating each name with the number of times it appears in the file. You do not need to write imports.arrow_forwardThe history teacher at your school needs help in grading a True/False test. The students’ IDs and test answers are stored in a file. The first entry in the file contains answers to the test in the form:TFFTFFTTTTFFTFTFTFTTEvery other entry in the file is the student ID, followed by a blank, followed by the student’s responses. For example, the entry:ABC54301 TFTFTFTT TFTFTFFTTFTindicates that the student ID is ABC54301 and the answer to question 1 is True, the answer to question 2 is False, and so on. This student did not answer question 9. The exam has 20 questions, and the class has more than 150 students. Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points. Write a program that processes the test data. The output should be the student’s ID, followed by the answers, followed by the test score, followed by the test grade. Assume the following grade scale:90%–100%, A; 80%–89.99%, B; 70%–79.99%, C; 60%–69.99%, D; and…arrow_forward
- create a class named FileUtils. Add a method static void copyFile(String source, String destination) method that copies the source file to the destination location. For example, if called as copyFile(“a.txt”, “b.txt”) the contents of the file “a.txt” would be copied into the file “b.txt.”a. You must write the code to copy the file using java.io.* classes (e.g. File, FileInputStream, FileOutputStream, etc.).b. Do not assume that the files will contain only text.c. You should try to copy efficiently (i.e. not a single byte at a time).d. It is suggested that you test your method by copying the provided files from the input directory to the output directory in your project.e. The method should rethrow any exceptions that may occur.arrow_forwardWrite a method public static intreadInFile(String line, File file) that returns the position numberof a line in the file filename or −1 if there is no such line or file.We assume that this file contains names of people with a name per line.Names (and hence lines) are listed in ascending alphabetical order in the file.We can not find the same line twice.arrow_forwardIs the character repeating problem Within the Utils class that is provided to you in "Requested Files" you are to modify the method isRepeatingCharacter(String s)If all of the individual characters in the string are the same, return the boolean value true when the method is finished. Otherwise, return false.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License