***Please show work and final output display. Objective: Text File I/0 and Regul
ID: 3730538 • Letter: #
Question
***Please show work and final output display.
Objective: Text File I/0 and Regular Expressions Note that both classes below should handle all exceptions that might be thrown within them. 1. Create a class that does the following: a. Reads the name of a file to create as the first command line argument. (Overwrite any file with the same name). b. Reads an integer value as the second command line argument. C. The program should generate as many random numbers as are specified in the second command line argument (from step b) with magnitudes between 1 and 1000 (both inclusive) and write them to the file. Use a seed of 152 for your random number generator. d. You must write only 5 numbers on each line and then begin a new line. (The last line may have less than 5 numbers.) Delimit the numbers on a line with the & character. The end of a line should be delimited by the # character. No other delimiters should be explicitly used. A sample output file for 12 numbers might look like this: 19834&4&235&6# 1278524840085&611# 55&2# 2. Create a second class that does the following: a. Reads the name of the file to open as a command line argument. (Check for incorrect usage). b. Reads in all of the numbers from that file using a Scanner. (Assume a file format identical to the file created in (1) and make sure you use regular expressions to specify the delimiter.) c. Displays, to the standard output, the count and average of all of those numbers.Explanation / Answer
Please find the classes below. Proper line by line explanation is provided in each class/ method.
Solution of Question #1 :
==================
OUTPUT FROM FILE :
=================
Enter file name : test.txt
Enter Number Count : 12
SOLUTION OF QUESTION #2 :
========================
OUTPUT :
=========
Enter file name : test.txt
COUNT = 12
AVERAGE = 664.0833
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.