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
Which of the following is a technique to improve internal validity
3241004551 [841]

The technique to improve internal validity is D) Addition of a control group.

<h3>What is internal validity?</h3>

Internal validity  serves as the  study  which bring about the establishment of a trustworthy cause-and-effect relationship  that can be found in treatment and an outcome.

it should be noted that  Internal validity also helps to eliminate alternative explanations , hence, The technique to improve internal validity is D) Addition of a control group.

Learn more about internal validity on:

brainly.com/question/968894

#SPJ1

COMPLETE QUESTOIN:

Which of the following is a technique to improve internal validity ____________?

A) Experimenter expectancy

B) Participant bias

C) Use of a confederate

D) Addition of a control group

4 0
2 years ago
A humpback whale is classified as a mammal while a basking shark is a fish.
kvasek [131]

The taxonomic classification that is the same for a humpback whale and a basking shark is Phylum.

<h3>What is Taxonomic Classification?</h3>

We want to find Which taxonomy classification are the same for a humpback whale and a basking shark.

A chordate in the animal kingdom is referred to as Kingdom Animalia of the phylum Chordata. This phylum is one that includes all the vertebrates and subphyla tunicates and cephalochordates.

Chordates have peculiar characteristics such as notochord, pharyngeal slits, nerve cord, and a tail.

Therefore, we can conclude that the taxonomic classification that is the same for a humpback whale and a basking shark is Phylum.

Read more about Taxonomic Classification at; brainly.com/question/21023329

8 0
2 years ago
Which assessment finding is most important as labor progresses
Elena L [17]

The assessment finding which is most important as labor progresses is the uterus relaxing completely between contractions during pregnancy.

<h3>What is Uterus?</h3>

This is also referred to as womb and is the location where the fetus grows and develops during pregnancy. The uterus is also described as a hollow organ with muscular walls and also performs other functions as menstruation, and as a secondary sex organ in females.

During labor, the uterus undergoes some form of contraction movements which leads to its relaxing so as to enable the fetus pass to the birth canal. It is then expunged to the vagina where the health professional can take safe delivery of the baby.

This is the therefore the main reason why this assessment is very important during labor.

Read more about Labor here brainly.com/question/1259611

#SPJ1

6 0
2 years ago
What would the volume of the gas be if the pressure is increased to 40 psi? in. 3.
Ugo [173]

Answer: 450

Explanation:

6 0
3 years ago
12) Ocean Square Kilometers % of Earth's Water Pacific 46.6% Atlantic 168,723,000 85,133,000 70,560,000 23.5% 19.5% Indian South
-Dominant- [34]

Answer:

fresh water

Explanation:

8 0
3 years ago
Other questions:
  • What is the ocean layer with very cold water, no sunlight, a high density and the greatest percentage of ocean water?
    15·1 answer
  • Self-disclosure is the ___of information about yourself that has been hidden from others
    6·1 answer
  • Can someone please help me solve this question , yes or no? just tell me why . please​
    10·1 answer
  • What are the different parts of the SAT
    13·2 answers
  • What is the greatest challenge you have ever faced? Did you overcome it? If yes, how? If no, what did you learn from the experie
    13·1 answer
  • Based on the given information, what is AE? 2 units 7 units 12 units 17 units.
    10·1 answer
  • which is an effective claim for this prompt? many towns have curfew laws requiring teenagers to be home at a given hour. curfew
    11·2 answers
  • How did joseph g mccoy help the cattle industry develop in texas.
    13·1 answer
  • Building sheep pens : darsh and darpan are fencing off a large rectangular area to build some temporary holding pens. to prep th
    13·1 answer
  • A store carries a wide variety of products such as clothes, furniture, and housewares, usually at higher prices than discount st
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!