Create a Concordance java program that will read a text file and output the list
ID: 3569840 • Letter: C
Question
Create a Concordance java program that will read a text file and output the list of words and the frequencies of each word -- Sorted alphabetically.
Requirements:
1. Make a Concordance class
2. Test class (to run the concordances)
Make your program read the "Obama's Inaugural address" (2009)
http://www.gutenberg.org/cache/epub/28001/pg28001.txt
(Havent learned the high-end java coding terms, so i'm trying to look for something that i can understand and works as it should! :) )
Any help is appreciated!
Explanation / Answer
import java.io.*; class cntwords { publicstaticvoid main(String args[]) throws IOException { try { FileReader fr = new FileReader("data.txt"); BufferedReader br = new BufferedReader(fr); String str; while((str = br.readLine()) != null) countwords(str); fr.close(); } catch(FileNotFoundException e) { System.out.println("File Not Found"); } catch(IOException e) { System.out.println("Exception : " + e); } } staticvoid countwords(String st) { int len,i,totwords=1,j=-1,k=0,freqarr[],temp; int cnt=0,flag=0; len = st.length(); char ch[]; String starr[],st1[]; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.