[Solved]Java Please Collections Streams Write Program Named Commonsense Reading Text File Pamphlet Q37151235
Java Please
Collections and Streams. Write a program namedCommonSense: You will be reading in a text file of the pamphlet .Read the file into a collection of your choice. Then analyze it.You need to include a menu that includes the following.
1) read in the file (user picks location from a FileDialog box)- put up a dialog box and allow the user to choose where to readthe file from, like we normally do remove the punctuation and makeit case insensitive – there is no output for this menu item. Youcould combine it with 1) if you remove the punctuation as you readit in.
2) Determine the number of words in the book. Print the number.– this is a single number which is the total number of words in thedocument. This may vary slightly depending on the definition ofwhat a word really is. Is a number a word? You can determine yourdefinition.
3) Determine the number of unique words in the book. Print thenumber. – this again may vary slightly but it should print out asingle number that is the number of unique words. Java and java arethe same word since we made this case insensitive in menu item2.
4) Print out a table of the number of words (total words – notunique ones) of each length (one character, two characters, etc).Sorted from shortest to longest. – So the output should be
something like
1 character words – 35
2 character words – 100
3 character words – 200 Etc.
Note again – total words – not unique ones. So the above outputindicates that there are 35 total words in the document that haveone character (I guess all of the occurrences of a and i).
5) Search for a given word. Determine how many times it appearsin the text. – ask the user for the word that they are looking for.Print out how many times it occurs in the document (caseinsensitive)
6) We want to know what words Payne likes to use in his books.When any of us write, we tend to overuse some words. This menu itemshould analyze the document and determine what are the ten wordsthat Payne uses the most. Again, let’s do it case insensitive andwithout considering punctuation. Use the output from menu item 2above.
7) Apply the cipher (see details below) to the original file andstore the encrypted output to a text file. User picks the locationof the original file (which is then encrypted) and the locationwhere to store the encrypted file back. You need to generate anencrypting array (details below). You will want to keep all thespacings, etc. in your document so, when you decode it, you getback the original file exactly as it was. For more secureencryption, it would be better to encode the spaces, etc. as well,or the user could start to guess the encryption scheme. You can trythis if you like. But as a minimum, I am asking that we encrypt thealphabetic letters in the document.
8) Read the encoded file back into memory. Decode the messageusing the encrypting array. Print out the first thirty lines of thereturned file. It should be identical to the first thirty lines ofthe original file.
9) End
Our Encryption Scheme
Have a method named createArray that is used to generate atwo-dimensional array we will utilize for encrypting the file. Itshould return this 2-D array. You will use this 2-D array in one ormore of your other methods for doing the actual encrypting. Your2-D array will have 52 rows and 2 columns. The first column shouldhave all of the character values between ‘a’ and ‘z’ and ‘A’ and‘Z’. Thus…52 rows. And please DO NOT HAVE 52 STATEMENTS TO DOTHIS!! The second column will be the matching character forencoding the first column. You need to RANDOMLY generate the 52values of the letters (caps and smalls) to encode. If I run yourprogram more than once, I should get a different encoding schemeeach time. When done, the array should look like:
a A, b F, c k, d B, e r, A g, B f, C T, D L, E s
Call this method. Then use this 2-D array to encrypt thedocument. For example, using the above table, the word ace wouldencrypt to Akr. NOTE: the second column has to be unique or youwill not be able to decrypt the file back to the original.
example of pamphlet – perhaps the sentiments contained in thefollowing pages are not yet sufficiently fashionable to procurethem general favor a long habit of not thinking a thing wrong givesit a superficial appearance of being right and raises at first aformidable outcry in defence of custom but tumult soon subsidestime makes more converts than reason
Expert Answer
Answer to Java Please Collections and Streams. Write a program named CommonSense: You will be reading in a text file of the pamphl… . . .
OR

