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 this quote from a campaign speech by Eugene Debs. “I am not a labor leader. I don't want you to follow me or anyone else. I
almond37 [142]

Answer:

For one, it looks like he's a Communist. Secondly, he believes that people who are willing to follow a leader can not be trusted to stay loyal.

8 0
3 years ago
Read 2 more answers
By the early twentieth century, 85 percent of Texans lived in urban areas. true or false
Sav [38]

By the early twentieth century, 85 percent of Texans lived in urban areas.

<h3>Where is Texas?</h3>

Texas is one of the states that make up the United States of America. Texas once had a large rural population who were mostly into farming. However, at the turn of the twentieth century most of the people of Texas have moved to urban areas. The reason for the migration to urban areas is to ensure that people get a better life and access better opportunities for decent employment.

Thus, it is a true statement that; "By the early twentieth century, 85 percent of Texans lived in urban areas." This implies that a very large degree of rural - urban migration had taken place in Texas by the twentieth century.

Learn more about Texas:brainly.com/question/14968290

#SPJ1

5 0
2 years ago
Awnser with ur Name and grade and ill giv 5 stars, feeling nice 2day
Nookie1986 [14]
I’ll take brainliest as well if your willing to give it.
Name: Fadinglight
Grade: 10th
5 0
2 years ago
Read 2 more answers
Scientists infer evolutionary relationships by comparing the early development of different
ryzh [129]

Scientists infer evolutionary relationships by comparing the early development of different organisms by phylogeny.

In scientific terms, the evolutionary relationship and history of an organism or cluster of organisms is termed its phylogeny. It describes the relationships of associate organism, like from that organisms it's thought to own evolved, to that species it's most closely connected, so forth.

Scientists collect information that enables them to create evolutionary relationships between organisms. Almost like a detective work, scientists  use proof to uncover the facts. Within the case of phylogeny, evolutionary investigations specialize in 2 styles of evidence which are morphologic and genetic.

To learn more about Phylogeny here

brainly.com/question/1426293

#SPJ4

4 0
2 years ago
Describe banquo in macbeth shakspear
liberstina [14]

Answer:

a dog

Explanation:

7 0
4 years ago
Other questions:
  • Using the data set (SCHL.Txt), investigate the effect of the categorical predictor schl (School location: 1 = Urban; 2 = Suburba
    7·1 answer
  • To change from one unit to another in the metric system
    8·1 answer
  • In typical engine lubrication systems, what components are the last to receive oil and the first to suffer from a lack of oil or
    14·2 answers
  • GPA is a number representing the average value of the accumulated final
    6·2 answers
  • Write the expression 44(4–7)(4) using a single exponent. 4–28 4–4 4–3 4–2.
    13·1 answer
  • A varies jointly as of the product of b and c. If a = 24 when b = 8 and c = 2, find b when a = 48 and c = 4.
    8·1 answer
  • In what situation would you likely have the highest waves?.
    9·1 answer
  • Evaluate if the following function is a good candidate to be placed in a library. Why or why not?.
    12·1 answer
  • Decide whether the sentence is grammatically correct or incorrect as written. ¿cuidas tu hermana todos los días? correct incorre
    13·1 answer
  • You have several options for how to spend your Saturdays. Your top options are volunteering with an animal rescue or mowing lawn
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!