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
Read the following sentence. In some cities, the penalty for littering includes hefty fines and community service. What is the d
NNADVOKAT [17]

Answer:

A lot

Explanation:

Plenty means like to much or a lot

Ex: My mom gave me plenty of chips.

3 0
2 years ago
Read 2 more answers
Please solve these questions <br> I need big help
yaroslaw [1]

Answer:

ñàáâäæãåā⣢€~π•√×∆¶¥€¢£™®©\℅[]

5 0
3 years ago
Anyone wanna be my best friend???
Aleks [24]

Answer:

meee

Explanation:

i wanna be your friend

6 0
3 years ago
Read 2 more answers
What is a surface current: please describe how they form, where they are located, and how they help affect climate?
Nadusha1986 [10]

Explanation:

large-scale surface ocean currents are driven by global wind systems that are fueled by energy from the Sun.

3 0
3 years ago
Tech A says that measuring alcohol content in gasoline involves using water. Tech B says that as lonv as the fuel pressure is co
Ira Lisetskai [31]

Answer:

A is is the answer it actually the right answer

Explanation:

gasoline contains water

4 0
4 years ago
Other questions:
  • In the figure below, ray was constructed starting from rays and . By using a compass D and G were marked equidistant from E on r
    13·1 answer
  • What is the main reason why wegener's continental drift hypothesis was rejected by his scientific community?
    9·2 answers
  • It has many satellites, one of which is titan. <br> What planet is it?
    10·2 answers
  • A storm forms over the central part of the U.S. what direction will the storm move?
    9·1 answer
  • Study Questions
    13·1 answer
  • Question 20 of 20
    6·1 answer
  • Noiiiiiiiiiiinj8bd\e
    6·1 answer
  • According to the passage, what is the difference between a poem and a story? a poem is difficult to read, while a story is enter
    5·1 answer
  • Can someone pleaseeee friend me! i need to get in touch with someone
    5·1 answer
  • Exercise physiology, like biomechanics, is a subdiscipline in the biophysical sphere.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!