qq1703105484

Programming Paradigms 2022: Java Coursework 1

The following files are all provided, they must be downloaded from moodle:

Comp1039_java.pdf. // this description file String (Java Platform SE 8 ).pdf // Java String API

Test.txt // an example file to be read in and analysed

Out.txt // an sample output, given the Test.txt as the input (Note, you don’t have to store the result in a file)

Write Java code that performs the following tasks:

  1. Read the content from the supplied text file ‘Test.txt’, find all the integer numbers, add them together, and then output to the screen their total value. The comma (‘,’) and white space is used to separate each literal in the file, so you should ignore them. For example, if “Drive ok 123, 24, 2.3” is given, your program should 147 to the console. [3 marks]
  2. Counts and output to the screen all the case insensitive word that only appear once. Again, you should ignore any comma or white space in the file. So, if “Drive drive, OK, ok by, 123 123, 23” is given, your program should return “by 23” (“” here is used to indicate “by 23” is a string, you don’t need to output “” to the console in your program). [3 marks]

Please note that I will be using a different Test.txt file but it will be called Test.txt and will be placed in the same directory as your files. Full mark will be given if your code works, if it doesn’t work correctly, marks will be given at the marker’s discretion for correct aspects of the code.

You are allowed to use any of the Java build-in methods in the Java String API. You may also find it useful to use the regular expression “\\s” to represent a single whitespace and “\\s+” to represent one or more whitespace characters.

If your code works for both tasks, additional marks will be awarded for the following features:

  1. Implement some form of exception handling (comment where this occurs)                    [1 mark]
  2. Implement some form of polymorphism (comment where this occurs)                            [1 mark]
  3. Make use of at least one interface (comment where this occurs)                                        [1 mark]
  4. Make use of at least one inner class (comment where this occurs)                                     [1 mark]

The file contains the main method should be named as AssessedCW1.java. You need to submit all your Java files include AssessedCW1.java to Moodle as a .zip file. After unzipping, your code will be tested by:

Javac AssessedCW1.java Java AssessedCW1

Deadline is 6pm Thursday the 28th of April Any Late Submission will receive 0 marks Plagiarism is not allowed I will use JPLAG

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐