[solved]-Task Assignment Write Class A9 Package Comp2120 Complete Javadoc Comments Follows Read Dat Q39034272
Your task for this assignment is to write a classA9 in package comp2120 withcomplete JavaDoc comments as follows:
- Read data in from a file (provided as args[0] to main())comprised of whitespace-separated double values into a suitableJava Collection Framework container class. Use java.util.Scanner todo this.
- Sort and multiply each container element by 3.14.
- Finally output the transformed double values to a file(provided as args[1] to main()) with intervening whitespace.
- NOTE: You are permitted to a whitespace can be output after thelast double before closing the file.
Start by writing the above code using System.in andSystem.out.print() as you’ve always done. Get that to work first.When it works, add the file code passing in the opened input fileto Scanner instead of System.in, and, call .print() and println()with the PrintWriter() variable instead of using thejava.lang.System object. (This is the easiest way to makeeverything work.)
You must:
- Handle exceptions, i.e.,
- If either/both files cannot be properly opened (i.e., open thefiles right away in main()) then output suitable error messages andquit without processing or outputting any data.
- If any exceptions occur while processing, then output asuitable message and do the following:
- If meaningful, close the output file (ignore any exceptions)and attempt to delete the file withjava.io.File.delete(). (Ifdelete() returns false output a message that the output file couldnot be deleted.)
- NOTE: This means you must use try … catch … finally in yourcode. The main item where exceptions can occur is when you try toopen the files. There are various exceptions that can occur, but,all file I/O exception classes in Java inherit from IOException–so you can catch (IOException e) to catch any and allfile-related exceptions.
You may combine, etc. as you see fit the above code. The keything is to read in the double values and output all of them sortedmultiplied by 3.14. If an IOException occurs, then you are todelete the output file.
Your assignment will be run with the “java” command similar tothis:
- java comp2120.A9 inputfile.dat outputfile.dat
i.e., your code must read in the doubles in inputfile.dat andoutput them sorted and multiplied by 3.14 in the fileoutputfile.dat. If main() is not passed two arguments, then outputan error message like this:
- Usage: comp2120.A9 <INPUT_FILE> <OUTPUT_FILE>
Expert Answer
Answer to Your task for this assignment is to write a class A9 in package comp2120 with complete JavaDoc comments as follows: Read… . . .
OR

