Question: [ ] the I ask ior Inis Lab Work Attempts Write a program that Unlimited counts the occurrences of each reserved word in a Java

[]
the I ask ior Inis Lab Work
Attempts
Write a program that
Unlimited
counts the occurrences of each reserved word in a Java code file whose name is read from the user (console) by using a hash set (java.util.HashSet),
stores each reserved word that is found in the file with its count by using a tree map (java.util. TreeMap),
and prints the reserved words in alphabetical order with the number of the occurrences for each word.
Note: Your program must ignore each reserved word that is contained in a comment or in a string.
Assume that the Java source code file given to your program is correct and assume also that the line comments (starting with //) and the multiline comments (between/* and */) do not overlap.
The given file for testing your program (TestFile.java) and the expected console output for that file are shown on the next slide.
See the given two example codes.
CountReservedWords.java A program that counts the reserved words in a Java source code file by using Java's own hash set implementation (java.util.HashSet) and prints the total count.
CountOccurrencesOfWords.java A program that counts the occurrences of words in a string and prints the words in alphabetical order with the number of the occurrences for each word by using Java's own tree map implementation (java.util.TreeMap).
 [] the I ask ior Inis Lab Work Attempts Write a

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!