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
How can photography allow us to view the world around us in different ways?
Ymorist [56]
It captures a single moment that one might not see with a naked eye. It shows the beauty and the essence of simple things in one exact moment. And it allows the viewer to take more time to reflect on what is captured and really find meaning within it.
6 0
3 years ago
Read 2 more answers
Formulas should follow the___
tatuchka [14]

Answer:

Order of operations

Explanation:

4 0
2 years ago
A mobile device user has entered her user ID and password to access an online account. The user immediately receives a text mess
tensa zangetsu [6.8K]

Answer:

A. Multifactor authentication

Explanation:

Multifactor authentication is a security system process that requires a user to verify his or her identity by providing two categories of credentials.

A mobile device user has entered her user ID and password to access an online account, she immediately receives a text message with a unique PIN or One Time Password (OTP) that must be entered before she is granted access to the account. This is an example of a multifactor authentication security method.

8 0
2 years ago
Which act requires enterprises to guard protected health information and implement policies and procedures to safeguard it?
bogdanovich [222]

Answer:

D. HIPAA (Health Insurance Portability and Accountability Act)

Explanation:

HIPAA which stands for Health Insurance Portability and Accountability Act, is an act designed by the US government in 1996 to guard patients' confidential health information and also implement policies and procedures to safeguard it. The act contains the required information and instruction for handling patients' medical health information. The law however gives patients (or their representatives) the right to access these information which as a matter of fact must be made available within 30 days from the day of request.

PS: Not sure why the option D in the question contains ' FTF '. I have taken it to be a typo because without it, the option is in itself complete.

7 0
3 years ago
When somthing is trustworthy we call it what?
Gnom [1K]

Answer:

dependable

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • Jennifer has written a short story for children. What should be her last step before she submits the story for publication?
    11·1 answer
  • This toolbar can be used to change the way the text in your presentation looks. Drawing
    5·2 answers
  • Which fingers should you use to type the reach keys?
    12·1 answer
  • Select one of the following strategies: active listening, sandwich technique, constructive feedback. in 2-5 paragraphs, define a
    11·1 answer
  • Why would you use a billeted list in a slide presentation?
    11·1 answer
  • Dallas is an analyst at an online retailer. He is great at creating representative diagrams showing the relationships between cu
    12·1 answer
  • Consider the following code: // Merge mailing list m2 into m1 void merge (MailingList m1, MailingList m2) { for (int i = 0; i &l
    12·1 answer
  • Interstate highway numbers Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 of 95) go north/south, an
    8·1 answer
  • Please help with this:
    10·1 answer
  • Lynn has created a quarterly sales report using a word processor. The document is confidential, and Lynn wants to secure it with
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!