Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a program written in Java. Write a simple line editor. Keep the entire te

ID: 3802057 • Letter: I

Question

I need a program written in Java.

Write a simple line editor. Keep the entire text in an ArrayList object, one line in a separate index position. Start the program with entering EDIT file, after which a prompt appears along with the line number. If the letter I is entered with a number n following it, then insert the text to be followed on line n. If I is not followed by a number, then insert the text on the current line. If D is entered with two numbers n and m,one n, or no number then delete lines n through m, line n, or the current line. Do the same with command L, which stands for listing lines. If A is entered, then append the text to the existing lines or the last line. Entry E signifies exit and saving a text file.

Example:

Input file: textin.txt

The first line

And another line

EDIT testin

1>The first line

2>

3> And another line

4> I 3

3> The second line

4> One more line

5> L

1>The first line

2>

3> The second line

4> One more line

5> And another line     // This is now line 5, not 3

5> D 2                          // line 5, since L was issued form line 5

4> L                             // line 4, since one line was deleted

1>The first line

2> The second line

3> One more line

4> And another line

5>D 2 4

4>L

1>The first line

2>A

1> not done yet

2> L

1>The first line not done yet

2> E

Output File: textout.txt

The first line not done yet

The lines that are left or changed after entering E must be saved in new text file. textout.txt

Explanation / Answer

Menu: m Delete line: dl
Load file: l Delete range: dr
Show all: sa Copy range: cr
Show line: sl Paste lines: pl
Show range: sr Write to file: w
New line: nl Quit: q
Edit line: el Write and quit: wq
-> nl

type line? (y/n): y
this is the first line
type line? (y/n): y
and a second line

type line? (y/n): y
and this is the third line
type line? (y/n): n

-> w

write to file: test.txt

-> sa

this is the first line
and a second line
and this is the third line
this is the first line
and a second line
and this is the third line

-> nl
insert after line number: 1
inserting after:
this is the first line
type line? (y/n): y
one and a half
type line? (y/n): y
one and three quarters
type line? (y/n): n

-> sa

this is the first line
one and a half
one and three quarters
and a second line
and this is the third line

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote