Question: How can I fix my code so it works? evilin vile otrat Yisfapies ont tieniter. 7 woit 1 itiat pankic class Fordcounts extenat fansoleProgram 8.4

How can I fix my code so it works?
How can I fix my code so it works? evilin vile otrat
Yisfapies ont tieniter. 7 woit 1 itiat pankic class Fordcounts extenat fansoleProgram
8.4 Word Counts 5. WordCounts.java 1. import java.util. *; 2 3 public
class WordCounts extends ConsoleProgram 4.{56publicvoidrun(){ HashMap h= new HashMap ( ; String
input = readline( Enter a string: "); String words = input.spilt(" ");

evilin vile otrat Yisfapies ont tieniter. 7 woit 1 itiat pankic class Fordcounts extenat fansoleProgram 8.4 Word Counts 5. WordCounts.java 1. import java.util. *; 2 3 public class WordCounts extends ConsoleProgram 4.{56publicvoidrun(){ HashMap h= new HashMap ( ; String input = readline( Enter a string: "); String words = input.spilt(" "); for(int i=0;i i++ ) \{ Integer num =h.get( words [i]) if ( num = null) num = new Integer (1); else num = new Integer ( num. intValue ()+1); h. put(words[i] . tolowerCase(), num); 3) \} printSortedHashMap(h); - This method tokes a HashMap of word counts and prints out each word and it's associated count in alphabetical order. eparam wordCount The Hashlap mapping words to each word's frequency count % private void printSortedilashMop(Hash Mapestring. Integers wordCount) . If Sort all the keys (words) in the HashMap Object keys - wordCount.keyset 0 , toArrayO; Arrays , sort(keys); 1f print out eoch word and it's associated count: for (Object word : keys) \& int val - mordCount, get (word): System,out, println(word +i+ val); Ors: 1. WordCounts.java: Line 8: You may have forgotten to declare readline(String) or it's out of scope. 2. WordCounts.java: Line 9: You may have forgotten to declare spilt(string) or it's out of scope. In this program you will ask the user for a Sting. and then output the count of every word in that String in alphabetical ordec. Yourll need to use a HashMap to do this. For example if the user entered: thelio nalle verld You'd paint out hello: 2 . world: 1 Since the word hello appeared twice and the word world appeared once. HiNT: Use the provided ariatsertebusinas method to print out the HashMap in alphabetical ordec

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!