1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maks197457 [2]
2 years ago
13

LAB: Word frequencies - methods Define a method named getWordFrequency that takes an array of strings, the size of the array, an

d a search word as parameters. Method getWordFrequency then returns the number of occurrences of the search word in the array parameter (case insensitive). Then, write a main program that reads a list of words into an array, calls method getWordFrequency repeatedly, and outputs the words in the arrays with their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain less than 20 words. Ex: If the input is: 5 hey Hi Mark hi mark the output is: hey 1 Hi 2 Mark 2 hi 2 mark 2 Hint: Use the equalsignoreCase() method for comparing strings, ignoring case. The program must define and call a method: public static int getWordFrequency(String[] wordsList, int listSize, String currWord) LAB ACTIVITY 8.45.1: LAB: Word frequencies - methods 0 / 10 LabProgram.java Load default template... Слд 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 /* Define your method here */ 6 7 public static void main(String[] args) { 8 /* Type your code here. */ 9 } 10 } 11 NO
Computers and Technology
1 answer:
BartSMP [9]2 years ago
5 0

Using the knowledge in computational language in JAVA it is possible to write the code being methods define a method named getWordFrequency that takes an array of strings

<h3>Writting the code in JAVA:</h3>

<em>import java.util.*;</em>

<em />

<em>public class WordFrequency {</em>

<em>        public static int getWordFrequency(String[] wordsList , int listSize , String currWord) {</em>

<em>                HashMap<String , Integer> hm = new HashMap<>();</em>

<em>                for(String st : wordsList) {</em>

<em>                        String str = st.toLowerCase();</em>

<em>                        hm.put(str, hm.getOrDefault(str, 0) + 1);</em>

<em>                }</em>

<em>                for(String st : wordsList) {</em>

<em>                        String str = st.toLowerCase();</em>

<em>                        System.out.println(st + " " + hm.get(str));</em>

<em>                }</em>

<em>                String currWordToLowerCase = currWord.toLowerCase();</em>

<em>                return hm.get(currWordToLowerCase);</em>

<em>        }</em>

<em>        public static void main(String[] args) {</em>

<em>                // TODO Auto-generated method stub</em>

<em>                String[] wordsList = {"hey" , "Hi" , "Mark" , "hi" , "mark"};</em>

<em>                int listSize = wordsList.length;</em>

<em>                String currWord = "hey";</em>

<em>                System.out.println("The frequency of " + currWord + " is : " + getWordFrequency(wordsList , listSize , currWord));</em>

<em>        }</em>

<em />

<em>}</em>

See more about JAVA at brainly.com/question/12978370

#SPJ1

You might be interested in
How much mobile data does maps use
aleksandrvk [35]
Open up setting, cellular option, and you can view the amount of mobile data each of your apps take
5 0
4 years ago
In what type of attack does the adversary leverage a position on a guest operating system to gain access to hardware resources a
il63 [147K]

Answer:

VM escape attack

Explanation:

<em>In a VM escape attack, the attacker exploits hypervisor vulnerabilities to gain control over resources reserved for other guest operating systems. Services operating on the guest may be exposed to the other attacks, but such attacks can only access data allotted to the same guest. In the event of a buffer overflow or directory traversal or the client in the case of cross-site scripting.</em>

6 0
2 years ago
Which of the following tasks can you perform using a word processor?
frutty [35]

Answer:

check a document for spelling errors

Explanation:

With a word processor, you can easily edit and make changes to a document, move text around in a document, add images, change fonts, check for spelling errors

3 0
3 years ago
What is the main advantage of using e-mail to complain about a service or product?
Dahasolnce [82]
The advantage of using email to complain about a service or product is that you are likely to get a faster response because this is the most common way in which complaints are tackled, and it also means you have a written record of the conversation between yourself and the company.
8 0
3 years ago
99 Point question
icang [17]
Smartart is your answer! Hope this helps
3 0
4 years ago
Read 2 more answers
Other questions:
  • Groups to which we belong are defined late in our development true or false
    11·1 answer
  • Universal containers has included its orders as an external data object in to Salesforce. You want to create a relationship betw
    7·1 answer
  • Which software application should be used to communicate in writing about an upcoming event?
    12·2 answers
  • people illegally download music over the internet although it's free it it is still illegal what do you choose to do? why
    11·1 answer
  • An expansion ____ is a long-narrow socket on the motherboard into which you can plug an expansion card.
    12·1 answer
  • Electronic business includes which of the following
    5·2 answers
  • Resumen sobres el correo electrónico​
    6·1 answer
  • Assume the following:
    10·1 answer
  • In a program you need to store identification numbers of 5 employees and their weekly gross pay.
    11·1 answer
  • Briefly the conceptual model of effective computer based instruction for adults outlining three units (output, Process and input
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!