Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Assignment 1 CP-213 Winter 2017 Due: Wednesday, January 25, 5 pm This assignment is worth 4% of the final grade. WARM-UP: INTPUT/OUTPUT & TEXT PROCESSING Write a Java program that processes a multi-line text entered from the keyboard and collects some statistics extracted from the text. INPUT SPECIFICATION A user enters multiple lines from keyboard; Empty line signifies the end of the input; Input is processed line by line and represents a text with the following properties: - every non-empty line is guaranteed to contain at least one word - some lines might contain references to number of unspecified items purchased (this will be correct representation of unsigned integer) and/or references to the dollar amounts spent on purchases (this will start with $ sign immediately followed by correct representation of a floating point number) - if line contains any of references mentioned above, it is still guaranteed to have at least one word - words are words over the English alphabet and lines will not contain any other non-alphabet characters (such as coma, period, quotation marks etc.) except mentioned above SAMPLE OF INPUT While traveling to London we stopped by a gas station to buy 2 coffees for $3.54 and 1 bottle of water for $2.75 Canadian The trip went pretty well except we got 2 speeding tickets for the total amount of $280 unbelievable OUTPUT SPECIFICATION Your program processes input and reports calculated statistics by printing the following information in the specified below order: Number of lines processed, average number of words per line, and total number of words Longest word in the processed text Total number of items purchased, total amount of dollars spent, and average purchase price Line with largest word count Line with largest average word length List of longest words from each line (one per line) Word DONE on the last line of output For example, in response to the above sample of input your program should print: Lines: 6 Average words per line: 6.0 Total word count: 36 Longest word is: unbelievable Items purchased: 5 Dollars spend: $286.29 Average price of item: $57.26 Line with largest word count is: The trip went pretty well except we got 2 speeding tickets Line with largest average word length is: While traveling to London we stopped List of longest words in each line is: traveling station coffees Canadian speeding unbelievable DONE If first entered line is empty, you program should output: Text is empty! DONE If input contains no references to items purchased (no integer values found in text) your program should output corresponding message instead of statistics of purchases. For example, if input is: Each registered participant may have at most two presentations during the conference All contents of registrations and abstracts should be in English Your abstract as a single PDF file must be uploaded on the conference management system as soon as possible but not later than the official deadline The output should be Lines: 4 Average words per line: 12.0 Total words count: 48 Longest word is: presentations No purchases have been made Line with largest word count is: Your abstract as a single PDF file must be uploaded on the conference management Line with largest average word length is Each registered participant may have at most two presentations during the conference List of longest words in each line is: presentations registrations conference possible DONE NOTE: Your program should not print anything else (e.g. it should not prompt user for input of lines). Your program has to start printing output after ALL input lines are entered and processed. If a line contains multiple words matching requirements (for example, multiple words with the same largest length), your program should use first of these words for the output. You can assume that input is always correct and valid. No exception handling is required. MINIMAL IMPLEMENTATION REQUIREMENTS: Your project needs to contain the following classes and methods: Immutable class Counters. Objects of this class will be used in your program to represent statistics collected while processing single line of input. Class Tools with static method ProcessLine (method header is shown below) public static Counters ProcessLine(String s) This method takes a line s as an argument and returns an object of type Counters that represents all statistics accumulated during this line processing. Class Processing with main method which reads input and processes it line by line. Use JavaDoc to document your code. Submit the code along with proper documentation. DO NOT FORGET TO VALIDATE YOUR SUMBISSION BEFORE YOU SUBMIT!