Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a program using Java or C# that counts the frequencies of each word in

ID: 656399 • Letter: 1

Question

1) Write a program using Java or C# that counts the frequencies of each word in a text, and output each word with its count and line numbers where it appears. We define a word as a contiguous sequence of non-white-space characters. (hint: split()) Note: different capitalizations of the same character sequence should be considered same word, e.g. Python and python, I and i. The input will be several lines with the empty line terminating the text (using text file for input is optional). Only alphabet characters and white spaces will be present in the input. The output is formatted as follows:

1. Print the input text

2. Each output line begins with a number indicating the frequency of the word, a white space, then the word itself, and a list of line numbers containing this word.

Sample Input

Python is a cool language but Java

is also cool since it is purely object oriented language

Sample Output

1 python 1

3 is 1 2

1 a 1

1 but 1

1 cool 1 2

1 even 2

1 object 2

1 oriented 2

1 it 2

1 language 1 2

1 Java 1

1 purely 2

1 since 2

Explanation / Answer

import java.io.*;

public class CountWordFrequency()

{

                Public static void main (String args[])

                {

                                                             String word, keys;

   Int count;

                                                             System.out.println(