[SOLVED] CST8284_521 - Assignment# 4

26.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (2 votes)

CST8284_521 – Assignment# 4

What to submit: WordOccurences.java
Challenge
Write a program (WordOccurrences.java) that would open any text based file and writes to a file the list of unique words along with their occurrence. A word can be a combination of any number of alphanumeric characters, from 1 and up.
The program would prompt the user to enter the path to the text file, opens it, reads the content, either one line at time or else, I will leave it up to you, splits the words based on white space, stores every unique word, and count its occurrence, which would be 1 by default for every word read and then the occurrence would increment for every additional occurrence of an existing word encountered. Treat uppercase and lowercase letters the same. Ignore punctuation.
The output of this program needs to be written into a file that should hold the same name of the input file but with “_Out” tagged to the end of its name, just before the .extension; i.e. the .txt for example. So, if input file is “MyInputFile.txt”, the output file should be “MyInputFile_Out.txt”.
No need for the input file to be very large but with enough data to cover the requirements.
The alignment of the occurrence needs to be one tab (\t) past the longest word in the file read.
Make use of the Map interface 😉
Here is a sample output:
Input File content (Yours needs to be a bit longer than this)
Write a program that would open any text based file and writes to a file the list of unique words along with their occurrence. A word can be a combination of any number of characters, from 1 and up.
Output File content
Write 1
a 4
program 1
that 1
would 1
open 1
any 2
text 1
based 1
file 2
and 2
writes 1
to 1
the 1
list 1
of 3
unique 1
words 1
along 1
with 1
their 1
occurrence 1
word 1
can 1
be 1
combination 1
number 1
characters 1
from 1
1 1
up 1

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.