Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 2 - Command Line and String Parsing You will be writing your code in a file called CSVTool.java. All imports have already been done

Task 2 - Command Line and String Parsing

You will be writing your code in a file called CSVTool.java. All imports have already been done for you. You should use Hashmaps this task, but you are not required to. You may additionally import Hashmaps if you use them.

Given a command line in the form of:

java CSVTool    ...  

You will be printing out the results of CSVTool to the console. CSVTool will always be given at least 2 arguments, the first argument will always be the query file and the arguments that follow will always be CSV files.

The query file will not contain duplicates. The data files may contain duplicates.

The query file will be a list of query terms separated by a new line. The data files will consist of query, value pairs separated by a new line. We have included some files of each type for you to inspect.

You will print out the following information:

  • The query that produced the greatest value. This value will be the sum of all the values that query corresponds to across all data files.
  • The query that appeared the most amount of times
  • The data file that matched the most amount of queries

In the event of any ties for the above metrics, you may return any of the ties.

In addition to the above, you will also print out general stats for both queries and data files.

For each query, you will print out the following on one line:

<# of data files that contained the query>   

For each data file, you will print out the following on one line:

<# of queries matched>   

If you implement this correctly, then you should match the output below exactly. Be aware of the order shown. Since order matters, you must be consistent with the order of queries and file names given.

Notice that in the first example below, mug comes before franchise. This is because mug comes before franchise in queries_1.txt. Additionally notice that data_1.csv comes before data_3.csv in the second example. This is because data_1.csv comes before data_3.csv. You will need to match this order to recieve points on this task.

$ java CSVTool queries_1.txt data_1.csv  Greatest query is franchise with value 79  Most common query is mug and occured 2 time(s)  The file with the most query matches is data_1.csv with 2 matches    Stats:  1 mug [data_1.csv]  1 franchise [data_1.csv]  0 pardon []  0 intention []  0 sip []  0 smile []    2 data_1.csv [mug, franchise]  $ java CSVTool queries_2.txt data_1.csv data_3.csv  Greatest query is estimate with value 36  Most common query is estimate and occured 1 time(s)  The file with the most query matches is data_3.csv with 1 matches    Stats:  0 composer []  1 estimate [data_3.csv]  0 buffet []    0 data_1.csv []  1 data_3.csv [estimate] 

To assist you with output formatting, we have provided the following (incomplete) code snippet:

System.out.println("Greatest query is " + /* your code here */ + " with value " + /* your code here */ );  System.out.println("Most common query is " + /* your code here */ + " and occured " + /* your code here */ + " time(s)");  System.out.println("The file with the most query matches is " + /* your code here */ + " with " + /* your code here */ + " matches");    System.out.println();  System.out.println("Stats:");  /* For each query */  System.out.println(/* # of data file that contained the query*/ + " " + /* the query */ + " " + /* List of all data files that contained the query */);    System.out.println();    /* For each data file */  System.out.println(/* # of queries matched*/ + " " + /* Data file name including extension */ + " " + /* List of all queries that matched to the data file */)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Gail Fayerman

1st Canadian Edition

9781118774113, 1118774116, 111803791X, 978-1118037911

More Books

Students also viewed these Programming questions

Question

=+f a pharmaceutical company g an advertising agency

Answered: 1 week ago

Question

What is meant by the term non-controlling interest (NCI)?

Answered: 1 week ago

Question

How important is foreign direct investment to the world economy?

Answered: 1 week ago