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
Why was it harder for beowulf to kill grendel's mother.
77julia77 [94]

Answer:

It was harder for Beowulf to kill Grendel's mother because Grendel's mother was an underwater swamp sort of monster

5 0
2 years ago
What idea is stressed in the passage? the desire for liberty the establishment of an oligarchy the dismantling of an acquired st
nignag [31]

Answer: c

The dismantling of an acquired state.

Explanation: just took it on edge.!

6 0
3 years ago
In the context of the second stanza, the near rhyming of "mended" (line 5) and "tendered" (line 8) serves to depict a relationsh
AlladinOne [14]

In any given poem, we can see that the use of rhyme can be used to show the relationship between lines so that the reader can better understand the line and message behind it/

<h3>What is a Stanza?</h3>

This refers to the group of lines which forms a metrical unit in a poem.

<h3>What is Rhyme?</h3>

This refers to the use of similar sounding words together in a given line and they can rhyme in a particular pattern.

Please note that your question is incomplete so I gave you a general overview to help you get a better understanding of the concept,

Read more about stanza here:

brainly.com/question/24963840

7 0
2 years ago
For an object that is speeding up at a constant rate in the positive direction,
Scrat [10]

Answer: it D

Explanation:

8 0
3 years ago
Read 2 more answers
A student creates a Venn diagram to analyze two cars that are discussed in a text. What should appear in the middle of the Venn
Alenkinab [10]
The similarities / characteristics the two cars share
4 0
3 years ago
Read 2 more answers
Other questions:
  • Which type of cell has a large, central vacuole that controls water pressure?
    13·2 answers
  • Relaxing on the beach, Alice put her towel flat on her picnic blanket and the towel are both rectangular, with the towel complet
    11·1 answer
  • What is a few sentances with words eaves and legacy.
    6·1 answer
  • Is someone know the answer?<br> Thank you.
    7·2 answers
  • Which school would likely be the least expensive to attend?
    8·2 answers
  • What negative effect can
    12·1 answer
  • How many grams are in 3. 00 moles of carbon.
    6·1 answer
  • How did prohibition affect society during the 1920s brainly
    12·1 answer
  • What enables a virtual reality headset to create a three-dimensional perspective for the user? brainly.
    13·1 answer
  • Of segments and , which of the segments has a greater area based on the given information? justify with your work. circle has ra
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!