Write a console program in Java that allows the user to specify a text file, opens the file, and prints a two-column table consisting of all the words in the file together with the number of times that each word appears. Words are space-delimited and case-sensitive. The table should list the words in alphabetical order. Proper code documentation should be included in the source code.

package myPackage;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import javax.swing.*;
class MyClass {
public static void main(String[] args) throws IOException {
String filename;
System.out.println("enter file name:");
Scanner s = new Scanner(System.in);
filename=s.nextLine();
System.out.println(filename);
FileReader fr=new FileReader(filename);
BufferedReader br=new BufferedReader(fr);
ArrayList<String> list=new
ArrayList<String>();
int i;
StringBuffer stringBuffer=new StringBuffer();
while((i=br.read())!=-1){
stringBuffer.append((char)i);
if((char)i==' ')
{
list.add(stringBuffer.toString());
stringBuffer.delete(0, stringBuffer.length());
}
}
list.add(stringBuffer.toString());
Map<String, Long> counts =new HashMap<>();
for( String a: list) {
if(counts.containsKey(a)) {
counts.put(a,
counts.get(a)+1);
}
else{ counts.put(a, 1L); }
}
Map<String, Long> treeMap = new TreeMap<String,
Long>(counts);
br.close();
fr.close();
s.close();
System.out.println(treeMap);
JFrame f;
f=new JFrame();
String[][] array = new String[treeMap.size()][2];
int count = 0;
for(Map.Entry<String,Long> entry : treeMap.entrySet()){
array[count][0] = entry.getKey();
array[count][1] = entry.getValue().toString();
count++;
}
String column[]={"words","count"};
JTable jt=new JTable(array,column) ;
jt.setBounds(30,40,200,300);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(300,400);
f.setVisible(true);
}
}
//output:
enter file name:
"C:\\Users\\sai.reddy\\Desktop\\IrisData.txt"
"C:\\Users\\sai.reddy\\Desktop\\IrisData.txt"
{Java =1, Proper =1, The =1, Words =1, Write =1, a =3, all =1,
allows =1, alphabetical =1, and =2, appears =1, are =1, be =1,
case-sensitive =1, code=1, code =1, consisting =1, console =1,
documentation =1, each =1, file =3, in =4, included =1, list =1,
number =1, of =2, opens =1, order =1, prints =1, program =1, should
=2, source =1, space-delimited =1, specify =1, table =2, text =1,
that =2, the =7, times =1, to =1, together =1, two-column =1, user
=1, with =1, word =1, words =2}
Write a console program in Java that allows the user to specify a text file, opens...
write a python program that prompts the user for a name of a text file, opens that file for reading , and tracks the unique words in a file and counts how many times they occur in the file. Your program should output the unique words and how often they occur in alphabetical order. Negative testing for a file that does not exist and an empty file should be implemented.
Write a JAVA program that prints the contents of a file to the console. On each line, output the line number. Ask the user to specify a file name.
(Count the occurrences of words in a text file) Rewrite Listing 21.9 to read the text from a text file. The text file is passed as a command-line argument. Words are delimited by white space characters, punctuation marks (, ; . : ?), quotation marks (' "), and parentheses. Count the words in a case-sensitive fashion (e.g., consider Good and good to be the same word). The words must start with a letter. Display the output of words in alphabetical...
JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...
Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program...
Homework IX-a Write a program that opens a text file, whose name you enter at the keyboard You will be using the file text.txt to test your program. Print out all of the individual, unique words contained in the file, in alphabetical order Print out the number of unique words appearing in text.txt. Call your program: YourName-HwrklXa.py Make sure that your name appears as a comment at the beginning of the program as well as on the output display showing...
Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...
Write a program in java that asks a user for a file name and prints the number of characters, words (separated by whitespace), and lines in that file. Then, it replaces each line of the file with its reverse. For example, if the file contains the following lines (Test1.txt): This is a test Hi there Output on the console: Number of characters: 22 Number of words: 6 Number of lines: 2 Data written to the file (Test1.txt): tset a si...
(Python 3) Write a program that reads the contents of a text file. The program should then create a dictionary in which the keys are individual words found in the file and the values are the number of times each word appears and a list that contains the line numbers in the file where the word (the key) is found. Then the program will create another text file. The file should contain an alphabetical listing of the words that are...
Write a program that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Store each word as an element of a set. USING PYTHON Please provide a screenshot of the input