Computers and Technology

Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the line associated with that number.
It should be like as this sample run follows.

Enter the input file name: quotes. xtxt
I cannot open the file quotes. xtxt - Please check the name and try again.
Enter the input file name: quotes. txt
The file has 16 lines.
Enter a line number [0 to quit]: 1
1: Hakuna Matata!
Enter a line number [0 to quit]: -1
Try again. Line number must be between 0 and 16
Enter a line number [0 to quit]: 16
16: Just keep swimming!
Enter a line number [0 to quit]: 17
Try again. Line number must be between 0 and 16
Enter a line number [0 to quit]: 5
5: It's kind of fun to do the impossible.
Enter a line number [0 to quit]: A
Try again. Please enter a number between 0 and 16
Enter a line number [0 to quit]: $
Try again. Please enter a number between 0 and 16
Enter a line number [0 to quit]: 4
4: To infinity and beyond!
Enter a line number [0 to quit]: 0

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:10, kaiya789
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, noah2o2o
These factors limit the ability to attach files to e-mail messages. location of sender recipient's ability to open file size of file type of operating system used
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, paolaviviana
Experimental data that is expressed using numbers is said to be
Answers: 1
image
Computers and Technology, 24.06.2019 13:30, lovecats12
To move an excel worksheet tab, simply right-click on it drag and drop it double-click on it delete it
Answers: 1
Do you know the correct answer?
Write a program that allows the user to navigate the lines of text in a file. The program should pro...

Questions in other subjects:

Konu
Mathematics, 06.03.2021 09:00
Konu
Mathematics, 06.03.2021 09:00
Konu
Physics, 06.03.2021 09:00
Konu
History, 06.03.2021 09:00