Here is a list of common errors that you may want to double check before submission:
Warm-up with Java programming. Get familiar with regular expression. Understand the wide application of regular expression.
You should pick out the identifiers from a text file, and write the output to a text file (named A1.output). Note that the output file should contain a line like "identifiers:5" . Here are the sample input and output files.The input will have multiple lines. Please note that in this sample program the following are not counted as identifiers:
If you can not pass test case 6, and you use [^a-zA-Z] as delimiter in Scanner, you can solve the problem by specifying the encoding as UTF-8, i.e., use
new Scanner(yourFile, "UTF-8")...
In this assignment you can suppose that there are no comments in the programs.
In the output file you should only write "identifiers:" followed by the number of identifiers. If there are multiple occurrences of an identifier in the input, you should only count it once. Don't write anything else into the output file.
You will write two different programs to do this:
Your programs should be able to run by typing:
%javac A11.java %java A11 A1.tiny %javac A12.java %java A12 A1.tiny
In this assignment, the output should be in a file called "A1.output". You should not use keyboard input. The input file name will be provided as the argument of the program, while the output file name is hard coded in your programs. i.e., your code regarding input and output can be like the following:
... new BufferedReader(new FileReader(args[0])); ... new BufferedWriter(new FileWriter("A1.output"));Your program should be tested on luna or bravo.
Please don't write unnecessarily long programs. The sample solutions for A11 and A12 consist of approximately 300 words altogether by PHP function str_word_count(), which are not written deliberately for short length and can be compacted into smaller sizes easily. Hence one mark is given if your wordcount is smaller than 300.
yourMark=0; if (A11.java, A12.java are not sent properly) return; for (each of A11, A12) if (it is compiled correctly) yourMark+=0.2; for (each of A11, A12){ if (your java program reads A1.tiny && generates result file A1.output) for (each of the 6 tests cases) if (it is correct) yourMark+=0.3; if youCode.length() < average(length of A11 in the class) yourMark+=0.5; } for (each day of your late submission) yourMark=yourMark*0.8; One bonus mark for the shortest code among the class.
You should submit A11.java and A12.java.