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
List 1 reason people invest in Cryptocurrency
Katarina [22]

Answer:

The common reason to invest in cryptocurrency is the desire for a reliable, long-term store of value.

Explanation:

8 0
2 years ago
Write a program that calculates the average rainfall for three months. The program should ask the user to enter the name of each
Eduardwww [97]

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

   Scanner input = new Scanner(System.in);

       System.out.println("Enter the month name:");

       String month1 = input.next();

       System.out.println("Enter the amount of rain for "+month1);

       double month1Rain = input.nextDouble();

       System.out.println("Enter the second month: ");

       String month2 = input.next();

       System.out.println("Enter the amount of rain for "+month2);

       double month2Rain = input.nextDouble();

       System.out.println("Enter the Third month: ");

       String month3 = input.next();

       System.out.println("Enter the amount of rain for "+month3);

       double month3Rain = input.nextDouble();

       double averageRainfall = (month1Rain+month2Rain+month3Rain)/3;

       System.out.printf("Average Rainfall is: %,.2f  ", averageRainfall);

   }

}

Explanation:

This is written in Java Programming language

  1. Import  the scanner class to prompt user for the inputs (Months and amount of rainfall for each month)
  2. Find the average of the three rainfall amount by adding up and dividing by 3
  3. Output the average. Pay particular attention to the use of java's printf in order to print the average to 2 decimal places
8 0
3 years ago
Functions of barriers include (mark all that apply): A. Define boundaries B. Design layout C. Deny access D. Delay access
gayaneshka [121]

Answer:

A. Define boundaries

C. Deny access

D. Delay access

Explanation:

A barrier is a material or structure used to prevent or block access. Barriers can either be natural or structural and are used for many purposes usually for security reasons. The following are functions of barriers either natural or structural:

  1. Define areas of boundaries
  2. Delay or slow access. Example is the use of speed bumps to slow down vehicles.
  3. Provide access to entrances such as the use of gates
  4. Deny access to unauthorized personnel and allowing authorized personnel.
4 0
3 years ago
FREE 10 POINTS THE EASIEST QUESTION EVER I AM NEW SO I DONT KNOW HOW TO MARK SOMEONE THE BRAINLEAST ????????????????????????????
umka2103 [35]

Usually you can just report the question as useless or just report in in general. But I myself have read some answers and they dont even pertain to the question, it confuses me alot

8 0
3 years ago
Read 2 more answers
Use the drop down menus to describe how adman can add shapes to his presentation
alina1380 [7]

Answer:

✔ Illustrations

✔ a crosshair

✔ left-click and drag

Explanation:

6 0
3 years ago
Other questions:
  • Name some of the file extensions for images and provide more information about one or two of them.
    12·1 answer
  • ________ are found on the motherboard and are used to attach your hard disk.
    6·1 answer
  • Select the correct answer.
    9·1 answer
  • Which computer network component allows data transfers from one computer to another through a telephone line?
    11·2 answers
  • Forensic computer investigators must _____.
    6·2 answers
  • Charles would like to move his internet browser window so that he can see his desktop.He should
    5·1 answer
  • To answer the research question "How am I going to find the information I need on the tople?" the best thing Georgia should
    15·1 answer
  • Is amazon a e-commerce website <br> o true <br> o false
    8·2 answers
  • What is algorithm and how does it works​
    11·2 answers
  • A ____________ protocol is software that provides or facilitates a connection in which no information is retained by either send
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!