Question: 5.13: A TextComparer Design and implement a program that compares two text input files, line by line, for equality. Print any lines that are not

5.13: A TextComparer Design and implement a program that compares two text input files, line by line, for equality. Print any lines that are not equivalent.

SPECIFICATION OF PROMPTS, LABELS AND OUTPUT: Your code should prompt for two filenames to identify the files. Each prompt should be "name of file to compare: ". The program produces no other output if it turns out that the files are identical. Otherwise, for every pair of lines in the two files that differ, the line number is printed out, followed by a colon and then on the next line the line from the first file is printed followed by, on the next line the line from the second file. (Thus each line difference in the files results in 3 lines of output: a line number and then the two lines from the files.) If one file finishes first then its lines should be represented in the output by the string null.

For example suppose that a file named f1 contained:

so long

it's been

good to know you

and a file named f2 contained:

so long

its been

good to know you and this dusty old dust storm is

then here how an interactive session with this program would look: name of file to compare: f1 name of file to compare: f2 2: it's been its been 4: null and this dusty old 5: null dust storm is

SPECIFICATION OF NAMES: Your application class should be called TextComparer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!