Question
JAVA QUESTION JAVADOC all parts Deliverables - Part1 program and output file Part 1- Only 1 Part !!!!!!!!!! Purpose:This will list the number of distinct
JAVA QUESTION
JAVADOC all parts
Deliverables - Part1 program and output file
Part 1- Only 1 Part !!!!!!!!!!
Purpose:This will list the number of distinct words in Green Eggs and Ham and provide a count for how many times each is used. I will leave the implementation up to you. What I want is output file that looks like
do :35
anywhere :6
good :2
mouse :8
mot :1
Like :1
would :17
ham :10
me :4
Here is a textfile: https://docs.google.com/document/d/1gyJEcO9PgjosRu2f_fj91ouHqVXXeZFnjVNWCaQo49s/edit?usp=sharing with the words. I would suggest you use a HashMap for this because a map is an object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.
The word would be the key and the value would start at 1 the first time you find the word in the file and then increment it each subsequent time you find the same word.
HASHMAP do not have duplicates You will need a try and catch to read a file.
Steps - use examples from Thursday
Lots of imports - file io and HashMap
Use try/catch to open file
Define a HashMap with a String key and an Integer value
Use while loop to read
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started