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
Monique is a single mom who is raising her three young children on her own. When she files her taxes this year, which tax status
pochemuha

Answer:

C. head of household

Explanation:

Taxation can be defined as the involuntary or compulsory fees levied on individuals or business entities by the government to generate revenues used for funding public institutions and activities.

The different types of tax include the following;

1. Income tax: a tax on the money made by workers in the state. This type of tax is paid by employees with respect to the amount of money they receive as their wages or salary.

2. Property tax: a tax based on the value of a person's home or business. It is mainly taxed on physical assets or properties such as land, building, cars, business, etc.

3. Sales tax: a tax that is a percent of the price of goods sold in retail stores. It is being paid by the consumers (buyers) of finished goods and services and then, transfered to the appropriate authorities by the seller.

In the United States of America, a head of household is a tax filing status for taxpayers that are saddled with the responsibility of paying more than half of the support and housing expenses (costs) of a qualifying person for at least a year. Also, to be eligible to file as a head of household, the taxpayer must be single or unmarried at the end of the year.

Generally, a head of household gets a lower tax rate and higher standard deductions than other taxpayers.

In this scenario, Monique is a single mom who is raising her three young children on her own. When she files her taxes this year, the tax status that will best fit her situation is head of household because she's solely responsible for catering to the needs of her kids.

6 0
2 years ago
What is the facific ring of fire?
Ann [662]

Answer:

Pacific ring of fire is a path along the Pacific Ocean characterized by active volcanoes and frequent earthquakes.

Explanation:

The spelling of the Pacific is wrong.

3 0
3 years ago
What is the molarity of a solution that contains 5.80 grams of nickel (ii) nitrate in 500. ml?
Rus_ich [418]

Answer:- 0.0634 M

Explanation:

molarity is defined as the number of moles of solute in 1 L of solution

molar mass of Ni(NO₃)₂ - 182.7 g/mol

number of moles of Ni(NO₃)₂ - 5.80 g/ 182.7 g/mol = 0.0317 mol

number of moles in 500 mL - 0.0317 mol

therefore number of moles in 1000 mL - 0.0317 mol / 500 mL x 1000 mL/L

molarity of the solution is - 0.0634 M

7 0
1 year ago
What title belongs in the circle labeled X in the diagram below?
drek231 [11]
Solar system is the answer. i believe.
3 0
2 years ago
Read 2 more answers
How does the writer introduce and develop the main idea of
drek231 [11]
The answer is By arguing that plants must have several signs
7 0
3 years ago
Other questions:
  • ESPAÑOL
    7·1 answer
  • Samantha is keen on joining the military. However, she does not know which military branch will help her achieve her career goal
    14·2 answers
  • The suggests that our "self" has aspects that control what we share with others. NEXT QUESTION ASK FOR HELP TURN IT IN
    13·1 answer
  • Yardımlaşmanın ve paylaşman8n önemi metin​
    8·1 answer
  • the function ​s(x) gives a​ person's average speed in miles per hour if he or she travels one mile in 60x seconds. use a linear
    8·1 answer
  • Select all that apply. Check the context clues formedley from the passage by sherwood anderson. Fiddlers tuned room above the st
    5·1 answer
  • Match the following regulations to their appropriate categories.
    9·1 answer
  • Anyone else needs help with any assignments or problems that they may have
    10·1 answer
  • The light dependent reaction of photosynthesis does not include.
    12·1 answer
  • Each of the following is a condition necessary for natural selection to occur except
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!