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).

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 2E: Create a program named FileComparison that compares two files. First, use a text editor such as...
icon
Related questions
Question
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 Speed limit exceeded.
7: 1631077133.1621683 NOTIFY Returning home.
8: 1631077133.1621709 WARNING High CPU temp.
9: 1631077133.1621737 WARNING Speed limit exceeded.
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.
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.
Transcribed Image Text: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 Speed limit exceeded. 7: 1631077133.1621683 NOTIFY Returning home. 8: 1631077133.1621709 WARNING High CPU temp. 9: 1631077133.1621737 WARNING Speed limit exceeded. 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. 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
Knowledge Booster
Graphical User Interface
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,