subject

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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
in 2007, floridians died in alcohol-related collisions.a.  501b.  1,051c.  5,015d.  10,839
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create the illusion of 3d in a 2d game
Answers: 3
question
Computers and Technology, 22.06.2019 14:30
If the polar bear were taken out of the food chain what would happen to the seal population the seal population would diminish the seal population would grow dramatically the seal population would stay the same the seal population would decrease slightly
Answers: 1
question
Computers and Technology, 22.06.2019 15:10
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
You know the right answer?
Write a program that allows the user to navigate the lines of text in a file. The program should pro...
Questions
question
Arts, 16.12.2020 22:00
question
Mathematics, 16.12.2020 22:00
question
Mathematics, 16.12.2020 22:00
question
Mathematics, 16.12.2020 22:00
question
Physics, 16.12.2020 22:00
question
Mathematics, 16.12.2020 22:00
Questions on the website: 13722363