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
Which list method allows elements in a sequence to be removed and added at either end of the structure?
Amanda [17]

Answer:

b) queue

Explanation:

Queue is also an abstract data type or a linear data structure, just like stack data structure, in which the first element is inserted from one end called the REAR(also called tail), and the removal of existing element takes place from the other end called as FRONT(also called head).

4 0
3 years ago
Read 2 more answers
Technician A says that Teflon sealing rings require special tools for proper installation. Technician B says that warming a Tefl
bezimeni [28]

Answer:Both Technicians A and B are correct.

Explanation:Teflon is a florinated polymer it is polytetrafluroethylene (PTFE). It is widely used in different fields and the making of materials for both home and industrial use. Teflon rings does requires special tools for proper installation which is called TEFLON RING INSTALLER.

Warming the a Teflon ring in water or oil at 130-140°F for about 5 minutes will help to soften the material for easier installation. cover wear ring grooves with plastic tape.

8 0
3 years ago
Which of the following is not an Operating System? (1 point)Windows
kobusy [5.1K]
The answers of the following are:

1.  The answer is Linux. It is not an Operating System.
2. Windows XP 2000 and Windows XP Home Edition have the same interface design. 
3. Linux is the operating systems which is considered to be open source.
4. Mac OS is an operating system which is considered to be the most popular with graphic and multimedia designers
5. The software programis the number and variety of programs available for a particular operating system.
4 0
3 years ago
In this problem, you will write three methods to:
gulaghasi [49]

Answer:

see explaination for program code

Explanation:

program code below:

class Names{

public static String[] makeNames(String[] array1, String[] array2){

if(array1.length == 0) return array2;

if(array2.length == 0) return array1;

String[] res = new String[array1.length*array2.length];

int k = 0;

for(int i=0;i<array1.length;i++){

for(int j=0;j<array2.length;j++){

res[k++] = array1[i] + " " + array2[j];

}

}

return res;

}

public static String[] makeNames(String[] array1, String[] array2, String[] array3){

return makeNames(makeNames(array1, array2), array3);

}

public static void print(String[] array){

for(String name : array){

System.out.println(name);

}

}

public static void main(String[] args) {

String[] first = {"David", "Mike", "Katie", "Lucy"};

String[] middle = {"A","B", "C", "D", "E"};

String[] last = {};

String[] names = makeNames(first, middle, last);

print(names);

print(names);

}

}

8 0
3 years ago
Samantha wants to begin searching for a job using the Web. The best source for her online search will probably be __________.
zalisa [80]

Answer:

C) A company's website

Explanation:

8 0
2 years ago
Other questions:
  • Nadia's productivity at work is being hurt due to the large quantity of unwanted e-mail she receives. What steps can she take to
    8·1 answer
  • Jana keeps receiving friend requests from strangers on a social media site. This is making her uncomfortable.
    15·2 answers
  • Using C#, declare two variables of type string and assign them a value "The "use" of quotations causes difficulties." (without t
    11·1 answer
  • A network technician is designing a network for a small company. The network technician needs to implement an email server and w
    7·1 answer
  • Before you insert a page break, what should you do? select the font you want to use for the text that comes after the page break
    8·1 answer
  • 10. What is "bandwidth"? (
    15·1 answer
  • Suppose you are choosing between four different desktop computers: one is Apple MacIntosh and the other three are PC-compatible
    15·1 answer
  • How many pieces can be connected on to a to an SPS​
    11·1 answer
  • Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correc
    9·2 answers
  • Select the four bad password ideas.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!