1. Design and implement a program that reads a series ofintegers from the user and continually prints their average afterevery reading. The input stops when the user enters “stop” as theinput value. Read each input value as a string, then check if it is“stop” or not. If the string is not “stop”, then, attempt toconvert it to an integer using the Integer.parseInt method. If thisprocess throws a NumberFormatException, meaning that the input isnot a valid integer, display an appropriate error message andprompt for the number again. Continue reading values until thestring “stop” has been entered.
2. Suppose a library is processing an input file containing thetitles of books in order to identify duplicates. Write a programthat reads all of the titles from an input file calledbookTitles.inp and writes them to an output file calledduplicateTitles.out. When complete, the output file should containall titles that are duplicated in the input file. Note that theduplicate titles should be written once, even though the input filemay contain same titles multiple times. If there are not duplicatetitles in the input file, the output file should be empty. Createthe input file using Notepad or another text editor, with one titleper line. Make sure you have a number of duplicates, including somewith three or more copies.