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
I am an 8th grade girl. Currently, I am applying for top boarding schools such as Phillips Academy and Choate. I just took my SS
garik1379 [7]

Answer:

yes you seem like a very smart and intelligent girl you seem like you put a lot of thought into that so i think you have a really high chance being that you acomplished all those things by the 8th grade i would consult with your parents before doing anything

8 0
3 years ago
The contribution limit for a Roth IRA is ______ the traditional IRA.<br>answer is equal too
Irina18 [472]

Answer:

Equal to.

Explanation:

The contribution limit for a Roth IRA Equal to. is the traditional IRA.

4 0
3 years ago
What instruction should the nurse include when developing a discharge teaching plan for a client who has been prescribed phenyto
marishachu [46]

The instruction that should be included by the nurse is: There is the potential of decreased effectiveness of birth control pills while taking phenytoin.

<h3>What is an Instruction?</h3>

This refers to the set of actions that a person needs to take based on clearly defined information.

Hence, we can see that with the administration of phenytoin to a patient, the nurse in charge needs to make a discharge teaching plan for the patient and tell the person the potential of decreased effectiveness of birth control pills while taking phenytoin.

Read more about nurse duties here:

brainly.com/question/24556952

#SPJ1

8 0
1 year ago
A 0. 75-kg ball is attached to a 1. 0-m rope and whirled in a vertical circle. The rope will break when the tension exceeds 450
8090 [49]

At the bottom of the circle, the ball is being pulled upward by tension in the rope and downward by its own weight, so that the net force on it is

∑ F = 450 N - (0.75 kg) g = (0.75 kg) a

where a is centripetal acceleration. At this maximum tension, the ball has a maximum centripetal acceleration of

a = (450 N - (0.75 kg) g) / (0.75 kg) = 590.2 m/s²

Then its maximum tangential speed v is such that

a = v² / (1.0 m)

⇒   v = √((1.0 m) a) ≈ 25 m/s

7 0
2 years ago
if you know the what you hear is how you died in your past life what is yours? i got "poison" "murder" "you cant help.." "me!" "
gogolik [260]

paypal me $10 and i will consider helping you !

4 0
3 years ago
Other questions:
  • How is eveyone doing mane ‍❤️‍‍?
    8·1 answer
  • The selijuks established their capital in
    14·1 answer
  • Help me please with this
    6·2 answers
  • What about the Haiku inspires Noni?
    8·1 answer
  • Odfghjkl;';lkjhgfdsxz;lkjhgfxcfghjkl;
    12·2 answers
  • What is the most likely consequence of open pit mining on plant life? a. A dramatic reduction in the variety of plant species b.
    14·2 answers
  • What is the volume of the cone to the nearest cubic meter? (use ​π = 3.14.) refer to your staar 8th grade math reference sheet f
    8·1 answer
  • The mood of this excerpt can best be described as confused. Delightful. Ominous. Righteous.
    12·2 answers
  • The four principal types of stress are __________. a. frustration, conflict, pressure, and anxiety b. frustration, conflict, pre
    5·1 answer
  • \If an electron is released from infinity, how fast will it be traveling after falling to within 1x10-10 m of a proton
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!