Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

No AI and use java, Write a program that asks the user for the name of a file and the number of lines to display.

No AI and use java, Write a program that asks the user for the name of a file and the number of
lines to display. The program than displays the first of those lines with the
line number prepended. If the file has fewer lines than the number of lines
entered by the user, the program displays all the lines in the file.
There are two conditions you should check for:
the number of lines read is equal to the number of lines to display
there's still more lines to read
Sample run 1:
Enter the name of the file: story1.txt
Enter the number of lines to display: 3
1: When the spiritual teacher and
2: his disciples began their evening
3: meditation, the cat who lived in
Sample run 2:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions