The delivery drones have a internal reporting and logging system that records events and issues during flights. These logfiles contain the last 1000 events/messages as well as their status codes. The Logfile Format By default, the logfiles are all called ‘logfile.txt’. Each logfile is exactly 1000 lines long. Each entry in the file consists of 4 fields: 1. a line number (starting at 0) 2. a POSIX timestamp 3. a message/event type 4. an event description Each field (line number, timestamp etc.) is separated by a space, except for the description which ends with a full stop. Log events come in three different types: NOTIFY, WARNING, and ERROR.     Task 1: Display Because the logfiles are so big, we would only like to display a certain number of lines at a time. We prompt the user to choose start and end line numbers and print all the lines from start to end (inclusive). The input constraints are as follows: 0  start  end  999 You can safely assume that the inputs will fall within that range. Instructions 1. Create a file called Display.java 2. Write a try-catch statement that attemps to create a Scanner object to read from the logfile (‘logfile.txt’). 3. If the file does not exist, catch the FileNotFoundException, print “Cannot find logfile!” then “Exiting. . . ” and quit the program. 4. If the file exists, prompt the user to enter start and end indices 5. Print out all the lines between the start and end line numbers (inclusive).   Sample Input/Output Example 1: Enter a start and end index separated by a space: 0 10 0: 1631077133.1621282 WARNING High CPU temp. 1: 1631077133.1621487 ERROR Carrier signal lost. 2: 1631077133.1621530 NOTIFY Waypoint set. 3: 1631077133.1621563 ERROR Motor failure. 4: 1631077133.1621597 NOTIFY Waypoint reached. 5: 1631077133.1621628 WARNING IMU sensor offset. 6: 1631077133.1621654 WARNING Rotor speed submoptimal. 7: 1631077133.1621683 NOTIFY Returning home. 8: 1631077133.1621709 WARNING High CPU temp. 9: 1631077133.1621737 WARNING Rotor speed submoptimal. 10: 1631077133.1621764 NOTIFY Rerouting. Example 2: Cannot find logfile! Exiting... Example 3: Enter a start and end index separated by a space: 499 512 499: 1631077133.1634748 ERROR Battery depleted. 500: 1631077133.1634772 WARNING IMU sensor offset. 501: 1631077133.1634796 WARNING High CPU temp. 502: 1631077133.1634822 NOTIFY Rerouting. 503: 1631077133.1634843 ERROR Carrier signal lost. 2 504: 1631077133.1634867 NOTIFY Rerouting. 505: 1631077133.1634893 ERROR Motor failure. 506: 1631077133.1634915 ERROR Carrier signal lost. 507: 1631077133.1634941 ERROR Battery depleted. 508: 1631077133.1634967 WARNING High CPU temp. 509: 1631077133.1634991 ERROR GPS offline. 510: 1631077133.1635013 WARNING Signal degradation. 511: 1631077133.1635036 WARNING Signal degradation. 512: 1631077133.1635070 NOTIFY Rerouting.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The delivery drones have a internal reporting and logging system that
records events and issues during flights. These logfiles contain the last 1000
events/messages as well as their status codes.
The Logfile Format
By default, the logfiles are all called ‘logfile.txt’. Each logfile is exactly 1000 lines
long.
Each entry in the file consists of 4 fields:
1. a line number (starting at 0)
2. a POSIX timestamp
3. a message/event type
4. an event description
Each field (line number, timestamp etc.) is separated by a space, except for the
description which ends with a full stop.
Log events come in three different types: NOTIFY, WARNING, and ERROR.

 

 

Task 1: Display


Because the logfiles are so big, we would only like to display a certain number of
lines at a time. We prompt the user to choose start and end line numbers and
print all the lines from start to end (inclusive).
The input constraints are as follows: 0  start  end  999
You can safely assume that the inputs will fall within that range.
Instructions
1. Create a file called Display.java
2. Write a try-catch statement that attemps to create a Scanner object to
read from the logfile (‘logfile.txt’).
3. If the file does not exist, catch the FileNotFoundException, print “Cannot
find logfile!” then “Exiting. . . ” and quit the program.
4. If the file exists, prompt the user to enter start and end indices
5. Print out all the lines between the start and end line numbers (inclusive).

 

Sample Input/Output Example 1:


Enter a start and end index separated by a space:
0 10
0: 1631077133.1621282 WARNING High CPU temp.
1: 1631077133.1621487 ERROR Carrier signal lost.
2: 1631077133.1621530 NOTIFY Waypoint set.
3: 1631077133.1621563 ERROR Motor failure.
4: 1631077133.1621597 NOTIFY Waypoint reached.
5: 1631077133.1621628 WARNING IMU sensor offset.
6: 1631077133.1621654 WARNING Rotor speed submoptimal.
7: 1631077133.1621683 NOTIFY Returning home.
8: 1631077133.1621709 WARNING High CPU temp.
9: 1631077133.1621737 WARNING Rotor speed submoptimal.
10: 1631077133.1621764 NOTIFY Rerouting.
Example 2:
Cannot find logfile!
Exiting...
Example 3:
Enter a start and end index separated by a space:
499 512
499: 1631077133.1634748 ERROR Battery depleted.
500: 1631077133.1634772 WARNING IMU sensor offset.
501: 1631077133.1634796 WARNING High CPU temp.
502: 1631077133.1634822 NOTIFY Rerouting.
503: 1631077133.1634843 ERROR Carrier signal lost.
2
504: 1631077133.1634867 NOTIFY Rerouting.
505: 1631077133.1634893 ERROR Motor failure.
506: 1631077133.1634915 ERROR Carrier signal lost.
507: 1631077133.1634941 ERROR Battery depleted.
508: 1631077133.1634967 WARNING High CPU temp.
509: 1631077133.1634991 ERROR GPS offline.
510: 1631077133.1635013 WARNING Signal degradation.
511: 1631077133.1635036 WARNING Signal degradation.
512: 1631077133.1635070 NOTIFY Rerouting.

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY