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
what is the purpose of this dialogue? to foreshadow a love scene to describe the setting to help build suspense to provide comic
kap26 [50]

The purpose of the dialogue between old Capulet and Lady Capulet is to: provide comic relief.

<h3>What is Comic Relief?</h3>

Comic relief can be described as an emotional tension that produces a relief by the interference of comic episode, especially of a drama.

The dialogue that ensued where Capulet requested for a sword, and instead, was offered a crutch by Lady Capulet, produces a comic relief in the drama.

Learn more about comic relief on:

brainly.com/question/361955

#SPJ1

6 0
2 years ago
Ping's Ice Cream Palace offers a special sundae that
jekas [21]
Let us assume number of toppings = n

Total weight of sundae = s

Quantity of Ice cream = 2 kilograms.

We need to discribe the total weight of the special sundae in kilograms by an inequality.
The sundae contains ice cream and number of toppings.

So the total weight of the sundae will be greater than the total weight of ice cream and number of toppings, because there would be some weight of the packing.

Therefore,
The total weight of the sundae > total weight of ice cream + weight of toppings.
s > 2 + n.

Where, s is the total weight of the sundae and n is the weight of toppings. I hope this was helpful!. :)
7 0
3 years ago
An object emits as much radiation than it absorbs. How would you expect the temperature of this object to change?.
olchik [2.2K]

Answer: Objects that are warmer emit more energetic radiation than those that are cooler and so they cool faster. Therefore, in the absence of an external heat ...

Explanation:

6 0
3 years ago
a high school had 1,200 students enrolled in 2003 and over 1,500 students in 2006. If the student population P grows as a linear
QveST [7]
Each year 100 students more
4 0
3 years ago
In a job interview, the interviewer is not the only one who should ask questions. You should have _____ questions prepared to as
Semmy [17]

Answer:

A.) 9 to 11

Explanation:

I believe that asking as many questions as possible is very useful especially during a job interview. This is so because it allows you a wide range of questions to chose from and to create in which can cover concerns about the general job description of the job in which you are further undergoing. Not only that but it even enables you to gain additional background about past experiences about the job as well as to list out any concerns that can possibly cause hazards or other dangers. To generalize, you get a very detailed concept of the job description and the environment, along with many of the employees with a long range of questions to chose from.

5 0
3 years ago
Other questions:
  • Simon is familiar with the way in which his old company has organized the human resources department. When he moves to a new com
    5·2 answers
  • Tables and charts comparing the government from five different states
    5·1 answer
  • The midlife transition is characterized by a. Self-examination. C. Both a and b b. A midlife crisis. D. Neither a nor b
    13·2 answers
  • Too much stimulation can lead children to be?
    7·1 answer
  • Please select the word from the list that best fits the definition.
    9·2 answers
  • Antique Accents tracks their daily profits and has found that the distribution of profits is approximately normal with a mean of
    9·1 answer
  • Notices for files:
    15·1 answer
  • Which of these main costs of college is the most easily changed?
    11·2 answers
  • What is the difference between an abyssal plain of the ocean and the plains of the continents? I need this ASAP
    14·1 answer
  • How many molecules of h2o are there in 0. 75 mol of h2o.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!