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]
1 year 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]1 year 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
What is the answer ????​
gtnhenbr [62]

Answer:

<h2>iv. NINGUNO DE LOS ANTERIORES</h2>

Explanation:

<h2>Hola</h2>
8 0
3 years ago
A computer connected to the Internet that asks for data is a(n) ________. Select one: A. server B. client C. aggregator D. surro
madreJ [45]

Answer:

client

Explanation:

The client makes a request for a service, and a server performs that service.

7 0
3 years ago
The open items on your computer are displayed here. menu bar open bar taskbar toolbar
Dennis_Churaev [7]
Maybe the answer is the Taskbar?
8 0
3 years ago
Read 2 more answers
Write the definition of a method twice, which receives an integer parameter and returns an integer that is twice the value of th
Kipish [7]
<span>public static int methodName(int a, int b){
      a = a * 2;
      b = b * 2;
}
</span><span>int result = doubling(5, 10<span>);
System.out.println(result);
//result would be 10, 20</span></span>
5 0
3 years ago
What is percent encoding and why is it used?
ehidna [41]

Answer:

 Percent encoding is the mechanism for encoding the information in the URI  (Uniform resource identifier) that basically transmitted the special variable or characters in the URI to the cloud platform.

It is also used in various application for transferring the data by using the HTTP requests.

Percent encoding is also known as uniform resource locator (URL) encoding. The percent encoding basically used to convert the non ASCII characters into URL format which is basically understandable to the all the web server and browsers. In percent encoding the percent sign is known as escape character.

7 0
2 years ago
Other questions:
  • The number of bits used to store color information about each pixel is called ____.
    13·1 answer
  • 1. Describe your Microsoft word skills that need to be improved upon the most. 2. Explain the Microsoft word skills you are most
    12·1 answer
  • Why is it so important that you know how much traffic dfs replication requires?
    13·2 answers
  • You have activated pop-up blockers in your web browser to prevent pop-up windows from continually interrupting your browsing exp
    14·2 answers
  • What method of the Math object can be used to return the largest value from the values that are passed to it?
    14·1 answer
  • Name two materials that we can burn in order to get energy from biomass
    9·1 answer
  • The elements in a long array of integers are roughly sorted in decreasing order. No more than 5 percent of the elements are out
    12·1 answer
  • Another way to create a new presentation is from the Home tab
    6·2 answers
  • Guys im getting the ps5 tomorrow :)​
    5·2 answers
  • How do programmers recognise patterns, generalise and abstract information
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!