Due by the end of Tuesday, 30 March 2021
Rename the program to NumberLines. The purpose of this program is to copy a text file, adding numbers to the lines.
First code revision is to change it so that it reads and saves all lines from the file instead of all integer values. You can use any/all of the following files to test your revisions:
When done, your program should print the lines of the file in reverse order.
This line is first.becomes
1. This line is first.
Revise it again so that the numbers aren't printed on blank lines.
NOTE: blank lines are still counted; they just doesn't have the number printed on them. See the expected output for the poems above:
true
for a yes answer,
and false
for a no.
The method is given a question to ask. It asks the question, then reads the user's answer. It repeats asking the question until it gets a yes or no. Accept the full words, of course, but also any one- or two-letter abbreviation of yes as a yes, and any one-letter abbreviation of no as a no.
Note: anything that "yes" starts with is counted as a yes; anything that "no" starts with is counted as a no -- except empty Strings, of course. The user should be able to enter answers using capital letters as well, so "N" should also count as a no.
NOTE: This can be done by creating a variable for the File object then adding a simple if control. if the file doesn't exist, OR if the user says it's OK to overwrite, then return a PrintWriter connected to that file. Because of short-circuit evaluation, the question about being OK to over-write will only be asked if the file exists.
If the user says the file can't be overwritten, then that can count as another "failure", so that any three reasons to request a new file name will result in the program ending.
Submit this/these files:
You will be graded on the following: