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
liubo4ka [24]
2 years ago
9

2.17 LAB: Word frequencies - methods Write a program that reads a list of words. Then, the program outputs those words and 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.
SAT
1 answer:
pickupchik [31]2 years ago
3 0

Using the knowledge in computational language in JAVA it is possible to write a code that reads a list of words.

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

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

<em>//class name LabClass</em>

<em>public class LabClass{</em>

<em>    //function getFrequencyOfWord with array wordList, ListSize and currWord as parameter</em>

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

<em>        int frequency = 0;</em>

<em>        //for loop for iteration </em>

<em>        for(int i=0; i<ListSize; i++){</em>

<em>            //if current word matches with words present in list</em>

<em>            //then increase the frequency by 1</em>

<em>            if(wordsList[i].compareTo(currWord)==0){</em>

<em>                frequency++;</em>

<em>            }</em>

<em>        }</em>

<em>        //return frequency at last </em>

<em>        return frequency;</em>

<em>    }</em>

<em>    //main function </em>

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

<em>        //creating object of Scanner class </em>

<em>        Scanner sc = new Scanner(System.in);</em>

<em>        int size;</em>

<em>        //asking user to input size of list </em>

<em>        System.out.println("Enter the size of list :");</em>

<em>        size = sc.nextInt();</em>

<em>        //creating array of same size as user input size</em>

<em>        String[] wordList = new String[size];</em>

<em>        sc.nextLine();</em>

<em>        //asking user to input array elements </em>

<em>        System.out.println("Enter list elements one by one :");</em>

<em>        for(int i =0; i<size; i++)</em>

<em>        {</em>

<em>            wordList[i] = sc.nextLine();</em>

<em>        }</em>

<em>        System.out.print("\n");</em>

<em>        sc.close();</em>

<em>        //calling function getFrequencyOfWord in every iteration by passing</em>

<em>        //required arguments to it </em>

<em>        for(int i=0; i<size; i++)</em>

<em>        {</em>

<em>            String currWord = wordList[i];</em>

<em>            int count = getFrequencyOfWord(wordList, size, currWord);</em>

<em>            //printing result </em>

<em>            System.err.println(currWord + " : " + count);</em>

<em>        }</em>

<em>    }</em>

<em>}</em>

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

#SPJ1

You might be interested in
Safety signs type and meaning
oksian1 [2.3K]
Stop-stop
green-go
red-stop
yellow-slow down/caution
6 0
3 years ago
Read 2 more answers
Each vendor is rated on several performance metrics. Can you identify the vendors that best meet amazon’s goals?.
vagabundo [1.1K]

There are different kinds of business. The vendor that best meet amazon’s goals is Vendor R. This is because it gives the best performance in terms of the parameters measured (see image attached)

  • Amazon Business  is known to give a specific shopping experience. There is free access to millions of products and services.

Vendors  are simply known to be any brand owners or wholesalers. They often  sell inventory to Amazon and can work with an Amazon Vendor Manager.

Learn more about Vendors from

brainly.com/question/25076850

4 0
2 years ago
What does "He will prevail" mean
olga_2 [115]
He will succeed at what he is doing
7 0
3 years ago
__________ generally makes drivers sloppy and aggressive. A. Alcohol B. LSD C. Marijuana D. Dramamine
devlian [24]
I WOULD SAY A BC NOT MUCH PEOPLE GET AGGRESSIVE WITH ALL THE OTHER ONES 
6 0
3 years ago
Read 2 more answers
All of these are NEGATIVE consequences of irrigation EXCEPT *
ludmilkaskok [199]
I think the answer is D. Because it doesn’t seem negative
4 0
3 years ago
Other questions:
  • QUESTION 19<br> Medicalization refers to<br> formning new drugs to treat a given illness?
    12·1 answer
  • The mean ACT composite score in a recent year is 20.8 with a standard deviation of 5.6. A random sample of 36 ACT composite scor
    15·1 answer
  • In elies orchard, 70% of the trees are apple trees. the rest of the trees are plum trees. what fraction of the trees are plum tr
    7·1 answer
  • How do you use present tense in your writing or your homework?
    5·1 answer
  • What is the difference between gases and nonmetal?
    10·2 answers
  • Use matrix T to find the following information. Which row contains the smallest nonzero element?
    9·1 answer
  • Nepal is such a beautiful country because of geographical diversity how.
    6·1 answer
  • Which term better describes the populations in the nations of northern europe?.
    12·2 answers
  • What is wollstonecraft’s purpose in citing rousseau’s theory? to applaud his theory to disprove his theory to agree with his the
    8·2 answers
  • Oregon project skills inventory checklist braille skills
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!