Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FOR YOUR INFO BELOW mport java.util. * ; import java.io . * ; class Main { public static void main ( String [ ] args

FOR YOUR INFO BELOW
mport java.util.*;
import java.io.*;
class Main {
public static void main(String[] args)
throws IOException
{
}
}
/*
==copy the text below into a new file ==
When the spiritual teacher and
his disciples began their evening
meditation, the cat who lived in
the monastery made such noise that
it distracted them. So the teacher
ordered that the cat be tied up
during the evening practice. Years
later, when the teacher died, the
cat continued to be tied up during
the meditation session. And when
the cat eventually died, another
cat was brought to the monastery
and tied up. Centuries later,
learned descendants of the
spiritual teacher wrote scholarly
treatises about the religious
significance of tying up a cat for
meditation practice.
*/
I NEED JAVA PROGRAM FOR THE FOLLOWING
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.
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:
Enter the name of the file: story1.txt
Enter the number of lines to display: 100
1: When the spiritual teacher and
2: his disciples began their evening
3: meditation, the cat who lived in
4: the monastery made such noise that
5: it distracted them. So the teacher
6: ordered that the cat be tied up
7: during the evening practice. Years
8: later, when the teacher died, the
9: cat continued to be tied up during
10: the meditation session. And when
11: the cat eventually died, another
12: cat was brought to the monastery
13: and tied up. Centuries later,
14: learned descendants of the
15: spiritual teacher wrote scholarly
16: treatises about the religious
17: significance of tying up a cat for
18: meditation practice.

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 Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago