Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**** Java expert please help me JAVA program below? Here is the requirement: Please show your program's output as example above --------- CountOccurrenceOfWords.java --------- import

**** Java expert please help me JAVA program below? Here is the requirement:

image text in transcribed

Please show your program's output as example above

---------CountOccurrenceOfWords.java---------

import java.util.*; public class CountOccurrenceOfWords { public static void main(String[] args) { // Set text in a string String text = "Good morning. Have a good class. " + "Have a good visit. Have fun!"; // Create a TreeMap to hold words as key and count as value Map map = new TreeMap(); String[] words = text.split("[ \t .,;:!?(){}]"); for (int i = 0; i 0) { if (!map.containsKey(key)) { map.put(key, 1); } else { int value = map.get(key); value++; map.put(key, value); } } } // Get all entries into a set Set> entrySet = map.entrySet(); // Get key and value from each entry for (Map.Entry entry: entrySet) System.out.println(entry.getKey() + "\t" + entry.getValue()); } }

Frequent Words Modify CountOccurrenceOfWords java. Your program should take a text file name as a command line argument. It should read the file and print the number of times the most-used word appears and, in ascending order, the words that occur most frequently. Ignore case when processing the words in the file. Your program may ignore punctuation. For example, if the file contained Sophie Sally and Jack were dachshunds Dachshunds are the best dogs and all dogs are better than cats The program's output should be Words that appear 2 times: and are dachshunds dogs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago