Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 17.7, Problem 17.7.2CP
Create a RandomAccessFi1e stream for the file address.dat to allow the updating of student information in the file. Create a DataOutputStream for the file address.dat. Explain the differences between these two statements.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that expands on the program below (i.e. reading data of each record in the file and storing it into data structure). The expansion involves writing all records to a file (use fprintf, call the name of the file csv). The displayed data must be accessed (and thus written) from data structure (i.e. array of structs). The format written to the file should be one line per record, with each field separated by a comma (‘,’)
program should then output the number of lines in the file.test the program by creating a text file with at least 10 lines of text (of any composition). Use notepad++ to create the data file.
#include<stdio.h>#include<stdlib.h>
//Structurestruct Person{ char name[10];int age;float wage; };
//Main int main (int argc, char **argv)
{ FILE* f; if (argc != 2)
{ printf("No filename in the argument"); return 1; } f = fopen(argv[1], "r"); if (f == NULL) { printf("The file cannot be opened successfully:…
Describe the advantages of using a FileInputStream over a FileReader when dealing with binary data.
The teacher at a school needs help grading an exam with a number of True/False questions. The students’ IDs and test answers are stored in a file. The first entry of the file contains the answer to the test in the form:
TTFTFTTTFTFTFFTTFTTF
Every other entry in the file is the student’s ID, followed by a blank, followed by the students’ response. For instance, the entry:
ABC54102 T FTFTFTTTFTTFTTF TF
The student’s ID is ABC54102, answer to question 1 is True, the answer to question 3 is False. Also, the student did not answer question 2 and question 18. The exam has 20 questions. Here is the grading policy: each correct answer is awarded two points, each wrong answer get -1 point, and no answer gets 0 point. 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 (total points), followed by the test grade. Assume the following grade scale will be used: 90%-100%, A; 80%-89.99%, B; 70%-79.99%, C; 60%-69.99%,…
Chapter 17 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 17.2 - What is a text file and what is a binary file? Can...Ch. 17.2 - How do you read or write text data in Java? What...Ch. 17.3 - Prob. 17.3.1CPCh. 17.3 - How is a Java character represented in the memory,...Ch. 17.3 - If you write the string ABC to an ASCII text file,...Ch. 17.3 - If you write the string 100 to an ASCII text file,...Ch. 17.3 - What is the encoding scheme for representing a...Ch. 17.4 - Prob. 17.4.1CPCh. 17.4 - Why should you always close streams? How do you...Ch. 17.4 - Prob. 17.4.3CP
Ch. 17.4 - Does FileInputStream/Fi1eOutputStream introduce...Ch. 17.4 - What will happen if you attempt to create an input...Ch. 17.4 - How do you append data to an existing text file...Ch. 17.4 - Prob. 17.4.7CPCh. 17.4 - What is written to a file using writeByte(91) on a...Ch. 17.4 - How do you check the end of a file in an input...Ch. 17.4 - What is wrong in the following code? Import...Ch. 17.4 - Suppose you run the following program on Windows...Ch. 17.4 - After the following program is finished, how many...Ch. 17.4 - For each of the following statements on a...Ch. 17.4 - What are the advantages of using buffered streams?...Ch. 17.5 - How does the program check if a file already...Ch. 17.5 - How does the program detect the end of the file...Ch. 17.5 - How does the program count the number of bytes...Ch. 17.6 - Prob. 17.6.1CPCh. 17.6 - Prob. 17.6.2CPCh. 17.6 - Is it true that any instance of...Ch. 17.6 - Prob. 17.6.4CPCh. 17.6 - Prob. 17.6.5CPCh. 17.6 - What will happen when you attempt to run the...Ch. 17.7 - Can RandomAccessFi1e streams read and write a data...Ch. 17.7 - Create a RandomAccessFi1e stream for the file...Ch. 17.7 - What happens if the file test.dat does not exist...Ch. 17 - (Create a text file) Write a program to create a...Ch. 17 - (Create a binary data file) Write a program to...Ch. 17 - (Sum all the integers in a binary data file)...Ch. 17 - (Convert a text file into UTF) Write a program...Ch. 17 - Prob. 17.5PECh. 17 - Prob. 17.6PECh. 17 - Prob. 17.7PECh. 17 - (Update count) Suppose that you wish to track how...Ch. 17 - (Address book) Write a program that stores,...Ch. 17 - (Split files) Suppose you want to back up a huge...Ch. 17 - (Split files GUI) Rewrite Exercise 17.10 with a...Ch. 17 - Prob. 17.12PECh. 17 - (Combine files GUI) Rewrite Exercise 17.12 with a...Ch. 17 - (Encrypt files) Encode the file by adding 5 to...Ch. 17 - (Decrypt files) Suppose a file is encrypted using...Ch. 17 - (Frequency of characters) Write a program that...Ch. 17 - (BitOutputStream) Implement a class named...Ch. 17 - (View bits) Write the following method that...Ch. 17 - (View hex) Write a program that prompts the user...Ch. 17 - (Hex editor) Write a GUI application that lets the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain what serializable isolation level is. Give an example of its use.
Database Concepts (7th Edition)
Fill in the blanks in each of the following: Each class declaration that begins with keyword must be stored in ...
Java How To Program (Early Objects)
A(n)________ occurs when a loop iterates one time too many or one time too few. a. general error b. logic error...
Starting out with Visual C# (4th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members: A field for the name of...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
To what class does the following constructor belong?
public Student (String name)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
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 generates student records in a database file. Your program should be able to generate at least 10 records. The format in the database should be: student name, student id The first student id should be 20180001, second id will be 20180001 and so forth. Show screenshot of scriptarrow_forwardWrite a program that reads a text file and outputs the 100 most frequent words in the text. You have to determine the appropriate data structure to make this task efficient and then develop an algorithm to solve the problem.arrow_forwardWrite a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. Assume also the last names and first names do not contain whitespaces. The program performs the following tasks: . Read the file name of the tsv file from the user. • Open the tsv file and read the student information. • Compute the average exam score of each student. • Assign a letter grade to each student based on the average exam score in the following scale: 。 A: 90=arrow_forwardWrite a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt. Output one student per row and…arrow_forwardWrite a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt. Output one student per row and…arrow_forwardWrite a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. Assume also the last names and first names do not contain whitespaces. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam scores, and letter grades of the…arrow_forwardComputer Science Write a python program that reads the data file https://archive.ics.uci.edu/ml/machine-learning-databases/eventdetection/CalIt2.data and finds the total count of outflow and the total count of inflow. The attributes in the file are as follows: 1. Flow ID: 7 is out flow, 9 is in flow 2. Date: MM/DD/YY 3. Time: HH:MM:SS 4. Count: Number of counts reported for the previous half hour Rows: Each half hour time slice is represented by 2 rows: one row for the out flow during that time period (ID=7) and one row for the in flow during that time period (ID=9) Hint: # Importing the dataset dataset = pd.read_csv('CalIt2.data') https://archive.ics.uci.edu/ml/machine-learning-databases/event-detection/CalIt2.data this link should work.arrow_forwardWrite a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in Studentlnfo.tsv. Assume the number of students is at least 1 and at most 20. The program performs the following tasks: Read the file name of the tsv file from the user. • Open the tsv file and read the student information. • Compute the average exam score of each student. • Assign a letter grade to each student based on the average exam score in the following scale: o A: 90 =< x o B: 80 =< x < 90 o C: 70 =< x < 80 o D: 60 =< x < 70 o F:x< 60 Compute the average of each exam. • Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt. Output one student per row and separate the…arrow_forwardDataInputStream reads bytes from the stream and converts them into appropriate primitive type values or strings.arrow_forwardFor the code for the txt file. Dim sw As Streamwriter = File.AppendText(fileName) I get an error for the file.AppendText(fileName). How do i fix this.arrow_forwardA temperature file consists of five records, each containing a temperature in degrees Fahrenheit. A program is to be written that will read the input temperature, convert it from degrees Fahrenheit to degrees Celsius and print both temperatures in two columns on a report. Column headings, which read ‘Degrees F’ and ‘Degrees C’, are to be printed at the top of the page. What ist he best solution algorithm to successfully implement the above question?arrow_forwardCreate a datafile that contains the first name, last name, gender, age, height, smoking preference, eye color and phone number. Add a variety of records to the file. A sample file looks like:  Write a program that opens the file and reads the records one by one. The program will skip any records where the gender preference is not a match. Of those records that match the gender preference, check to see if the age and height are between the maximum and minum preferences. Then check to see if the smoking preference and eye color are also a match. If at least 3 of the remaining fields match, consider the record a partial match, and print it in the report. If all 4 of the remaining fields match, the record is a perfect match and print it in the report with an asterisk next to it. At the end of the program, close the file and report how many total records there were of the specified gender, how many were a partial match, and how many were a perfect match.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
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