This problem set covers material from Chapters 9 and 10.
This homework does not need to be turned in. However, doing it will be excellent practice
for the final exam and you are welcome to show it to me for feedback.
General guidelines:
Write a program that asks the user for the names of two files: an input file, which contains a list of items to be completed, and an output file. Your program should then use the list of items in the input file to write a numbered to-do list to the output file. Specifically, the output file should start with the line My To-dos:, followed by numbered lines from the input file.
For example, if the input file is:
Finish my Java homework.
Buy milk.
Do laundry.
Update webpage.
Then the output file would be (exactly):
My To-dos:
1. Finish my Java homework.
2. Buy milk.
3. Do laundry.
4. Update webpage.
Rewrite your Guessing Game program from Problem Set 3 to use Exceptions to handle invalid guesses. (You can also write a new version of the whole program.)
Specifically, once the user enters a guess, you should throw an exception if the guess is out of range. i.e. if the user is told to guess a number between 1 and 100, but enters 1001, then the code should thrown an exception with a helpful error message. Additionally, the method Integer.parseInt throws a NumberFormatException when it receives a String that can't be converted to an integer.
Your code should also catch the above Exceptions, show the user an error message, and ask the user to re-enter their guess.
Hint: One way to do this is to write a helper method which asks the user for their guess, and either returns a valid guess or throws an Exception. You can then call this helper method from your main method, using a try-catch block to handle any Exceptions.