
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
assume the file data.dat contains a sequence of binary data. write a program that does the following:
displays the first 5 bytes stored in the file. each byte should be displayed on a separate line.
starting with byte 0, displays every even-numbered byte in the file. (in other words, display byte 0, byte 2, byte 4, and so on.) each byte should be displayed on a separate line.
starting with byte 1, displays every odd-numbered byte in the file. (in other words, display byte 1, byte 3, byte 5, and so on.) each byte should be displayed on a separate line.
displays the last 5 bytes stored in the file, in reverse order. (display the last byte, then the next-to-last byte, and so on.) each byte should be displayed on a separate line.
handle exceptions in the following manner:
if a filenotfoundexception is thrown, the program should display the string "file error".
if an eofexception is thrown, the program should display the string "eof error".
if any other exception is thrown, the program should display the string "error".
the name of your program class must be datadisplay.
![M Inbox (X
← → C
X
HH
Institut X
New Tab M Gmail
Inbox X P Studen X ℗ Chapte X ℗ Chapte x M MyOpe x O Mail - FX [Solved X G Assume X
revel-ise.pearson.com/courses/63091c45093a8566d41c45cd/pages/urn:pearson:entity:68b1e01d-3ffd-48c0-8a6e-63e23c1e5cd1?source=contents
Estudia fichas para l...
0816ExamGEOans.p... ▸ YouTube
Type here to search
</>
</>
O
Maps
8:
GregEn directo O Fichas de aprendiza...
Question 1 of 1
Assume the file data.dat contains a sequence of binary data. Write a
program that does the following:
• Displays the first 5 bytes stored in the file. Each byte should be displayed
on a separate line.
Starting with byte 0, displays every even-numbered byte in the file. (In
other words, display byte 0, byte 2, byte 4, and so on.) Each byte should
be displayed on a separate line.
• Starting with byte 1, displays every odd-numbered byte in the file. (In
other words, display byte 1, byte 3, byte 5, and so on.) Each byte should
be displayed on a separate line.
Displays the last 5 bytes stored in the file, in reverse order. (Display the
last byte, then the next-to-last byte, and so on.) Each byte should be
displayed on a separate line.
C written X
Fichas de aprendiza...
Handle exceptions in the following manner:
• If a FileNotFoundException is thrown, the program should display
the string "File Error".
• If an EOFException is thrown, the program should display the string
"EOF Error".
• If any other exception is thrown, the program should display the string
"Error".
The name of your program class must be DataDisplay.
1 public class DataDisplay
2 = {
3
4-
5
6
7
public static void main(String[] args)
{
int number;
String str = "data.dat";
try
{
amazon
9
G cop 28 x b Search x +
Fichas de aprendiza... OFichas de aprendiza...
S&P 500 -1.68%
<
•
☆
Free Computers Fla...
◄»)⠀⠀⠀
0
1:48 PM
12/6/2022
X
:](https://content.bartleby.com/qna-images/question/98e670cd-4d6d-4683-a173-616a918751aa/e423e1af-7b61-4816-b30f-97e76c69a8c4/fz88js_thumbnail.png)
Transcribed Image Text:M Inbox (X
← → C
X
HH
Institut X
New Tab M Gmail
Inbox X P Studen X ℗ Chapte X ℗ Chapte x M MyOpe x O Mail - FX [Solved X G Assume X
revel-ise.pearson.com/courses/63091c45093a8566d41c45cd/pages/urn:pearson:entity:68b1e01d-3ffd-48c0-8a6e-63e23c1e5cd1?source=contents
Estudia fichas para l...
0816ExamGEOans.p... ▸ YouTube
Type here to search
</>
</>
O
Maps
8:
GregEn directo O Fichas de aprendiza...
Question 1 of 1
Assume the file data.dat contains a sequence of binary data. Write a
program that does the following:
• Displays the first 5 bytes stored in the file. Each byte should be displayed
on a separate line.
Starting with byte 0, displays every even-numbered byte in the file. (In
other words, display byte 0, byte 2, byte 4, and so on.) Each byte should
be displayed on a separate line.
• Starting with byte 1, displays every odd-numbered byte in the file. (In
other words, display byte 1, byte 3, byte 5, and so on.) Each byte should
be displayed on a separate line.
Displays the last 5 bytes stored in the file, in reverse order. (Display the
last byte, then the next-to-last byte, and so on.) Each byte should be
displayed on a separate line.
C written X
Fichas de aprendiza...
Handle exceptions in the following manner:
• If a FileNotFoundException is thrown, the program should display
the string "File Error".
• If an EOFException is thrown, the program should display the string
"EOF Error".
• If any other exception is thrown, the program should display the string
"Error".
The name of your program class must be DataDisplay.
1 public class DataDisplay
2 = {
3
4-
5
6
7
public static void main(String[] args)
{
int number;
String str = "data.dat";
try
{
amazon
9
G cop 28 x b Search x +
Fichas de aprendiza... OFichas de aprendiza...
S&P 500 -1.68%
<
•
☆
Free Computers Fla...
◄»)⠀⠀⠀
0
1:48 PM
12/6/2022
X
:
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images

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
- im usually using python Write a program named filemaker.py that will be used to store the first name and age of some friends in a text file named friends.txt. The program must use a while loop that prompts the user to enter the first name and age of each friend. Each of these entries should be written to its own line in the text file (2 lines of data per friend). The while loop should repeat until the user presses Enter (Return on a Mac) for the name. Then, the file should be closed and a message should be displayed. See Sample Output.SAMPLE OUTPUT Enter first name of friend or Enter to quit DennyEnter age (integer) of this friend 24Enter first name of friend or Enter to quit PennyEnter age (integer) of this friend 28Enter first name of friend or Enter to quit LennyEnter age (integer) of this friend 20Enter first name of friend or Enter to quit JennyEnter age (integer) of this friend 24Enter first name of friend or Enter to quit File was createdarrow_forwardprogram - python Write a program using a for loop that creates a file and adds even numbers the integers 1 through 20 loop to the file. Name the file numbers. txt. Then perform the following on the file: Read all of the numbers stored in the file and calculate their total. Display all the numbers in the file and the calculated total Using a for loop add the following numbers to the file 21 through 30 Delete the following numbers from the file 24, 25, 26 (using a temp.txt file) Change the number 10 to 50 (using a temp.txt file) Hint: if you want to use ! Use module os that is part of Python to manipulate files.: import os. You can use functions that come with “os” module. Functions remove and rename can be used as explained below. rename(old_name,new_name):This function renames the old_name to new_name). remove(filename)method in Python is used to remove or delete a file.arrow_forwardChapter 4. PC #6. File Letter Counter (page 264) Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Class name: FileLetterCounter Hints: Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0. Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop.arrow_forward
- PYTHON: I need to get the avg statement out of the loop so that the output prints correctly. Any suggestions. Write 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…arrow_forwardGiven the following, write a code SEGMENT that does the following: Creates a string variable to store a file name (to be entered by the user) Requests the input file name from the user and stores the name in a variable Opens the input file using the entered file name Tests the STATE of the file open. If the file does not open, output a message to the user exit the program Be sure to: Include the necessary header files Declare necessary variablesarrow_forwardQI: Write a program to calculate the average of four integer score, and find the grade for 7 students. The program should do the following: 1. Read the first, second name and the four score of the 7 student from the file (E:lexam.txt), 2. Calculate the average and find the grade of the average by using the if and if else. 3. Save the first, second name, average and the grade for each student in file (E:grade.txt). (10 columns for the first and second name. 4 columns, precision 2, for the average and grade)arrow_forward
- Q1: Write a python code to read data from a file "file1.txt" and then write the data to another "file "file2.txt 4:30arrow_forwardWhen an input file is opened, its read position is initially set to the first item in the file. True or Falsearrow_forwardShow two different ways to reset the file position pointer to the beginning of the filearrow_forward
- 2. This involves a .txt file with one thousand rows of random numbers (between 1-1000) Using Python, create a program to perform this task, with 3 methods of doing this: Read the entire contents of file1.txt into memory, then process each row. Read one row of file1.txt at a time and process it. Split file1.txt into 2 parts and read each part into memory separately.arrow_forwardWrite a program using a for loop that creates a file and adds odd numbers that are in the integers 1 through 20 to the file. Name the file as numbers.txt. Then perform the following on the file: Read all of the numbers stored in the file and calculate their total. Display all the numbers in the file and the calculated total Using a for loop add the following numbers to the file 21 through 30 Delete the following numbers from the file 24, 25, 26 (using a temp.txt file) Change the number 11 to 50 (using a temp.txt file)arrow_forward
arrow_back_ios
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