Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Note: Only basic java knowledge, just started the course This class contains a main method, declared with the usual method header:

Need help writing this class:

Note: Only basic java knowledge, just started the course

This class contains a main method, declared with the usual method header: public static void main(String[] args) You can implement any other methods that you want to in this class, but they must be declared as private methods. The input to the program will consist of two files: a file to compress and a file containing the compression codes. The output will be the compressed file. In this class you must implement the algorithm described in Section 3. To execute your program from the command line you must type java Compress fileName compressionCodesName 5 where fileName is the name of the file to compress and compressionCodesName is the name of the file storing the compression codes. The compressed file must be stored in a file with the same name as the original one, but with extension ".zzz". For example if the name of the input file is test.txt then the name of the compressed file must be test.zzz. If you are using Eclipse, you need to specify the names of the two input files in the list of program arguments of Eclipse. Note that you need to store the input files in the same folder where Eclipse has the src folder, otherwise Eclipse will not be able to find them. Note that within method main you can access the names of the two input files through the parameter args: args[0] stores the name of the first file and args[1] stores the name of the second file. For example, if the program is executed like this: java Compress text7.txt codes.txt Then we can, for example, print the names of the files from within method main as: public static void main(String[] args) { System.out.println("Name of file to compress: "+args[0]); System.out.println("Name of file storing compression codes: "+args[1]); To get the name of the output file you can use, for example, the following code: String outputName = args[0].substring(0, args[0].length() - 3) + "zzz"; Method substring will return the name of the input file (args[0]) minus its last 3 characters (that should contain the extension "txt).

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question