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
At 900 ∘c,kc=0. 0108 for the reaction caco3(s)←→cao(s)+co2(g) a mixture of caco3, cao, and co2 is placed in a 10. 0-l vessel at
Mrac [35]

The concentration of CaCO3 increases in all cases because Q> K.

<h3>What is equilibrium?</h3>

A chemical reaction is said to have attained equilibrium when the rate of forward reaction is equal to the rate of reverse reaction. We are told that the Kc of the reaction is 0. 0108.

In the first case:

CaCO3 - 15.0 g/100g/mol/10 L = 0.015 M

CaO - 15.0 g/56 g/mol/10 L = 0.027 M

CO2 - 4.25 g/44 g/mol / 10 L = 0.0096 M

Q = [0.027] [0.0096]/0.015

Q = 0.017

Since Q > K, the concentration of CaCO3 increases

In the second case;

CaCO3 -  2.5 g/100g/mol/10 L =0.0025 M

CaO - 25.0 g/56 g/mol/10 L = 0.045 M

CO2 - 5.66 g/44 g/mol / 10 L = 0.013 M

Q = [0.045 ] [ 0.013]/[0.0025 ]

Q = 0.23

Q > K the concentration of CaCO3 increases

In the third case;

CaCO3 - 30.5 g/100g/mol/10 L =0.031 M

CaO - 25.5 g/56 g/mol/10 L =0.046 M

CO2 - 6.48 g//44 g/mol / 10 L = 0.015 M

Q = [0.046] [ 0.015]/[0.031]

Q = 0.022

Q> K hence the concentration of CaCO3 increases

Missing parts: At 900oC, Kc = 0.0108 for the reaction: CaCO3(s) <===> CaO(s) + CO2(g) A mixture of CaCO3, CaO, and CO2 is placed in a 10.0 Liter vessel at 900oC. For the following mixtures, will the amount of CaCO3 increase, decrease, or remain the same as the system approaches equilibrium? CaCO3 CaO CO2 At Equilibrium, CaCO3 will ?? 15.0 g 15.0 g 4.25 g Answer 2.5 g 25.0 g 5.66 g Answer 30.5 g 25.5 g 6.48 g Answer

Learn more about equilibrium: brainly.com/question/17960050

4 0
2 years ago
Can someone help me with this and please show your steps or what you did ASAP
podryga [215]
The answer to the question

7 0
3 years ago
At standard pressure which element has a melting point higher than standard temperature.
Komok [63]

The element that would melt at a higher temperature than the standard temperature is iron (Fe).

<h3>Melting point</h3>

The term melting point refers to the point where a solid is converted to a liquid. A pure substance has a sharp melting point while an impure substance melts over a temperature range.

Metals have a very high melting point hence the element that would melt at a higher temperature than the standard temperature is iron (Fe).

Missing parts:

At standard pressure, which element has a melting point higher than standard temperature?

(1) F2 (3) Fe

(2) Br2 (4) Hg

Learn more about melting point: brainly.com/question/491382

8 0
2 years ago
a mass of gas under constant pressure occupies a volume of 0.5 m3 at a temperature of 20 degrees Celsius using the formula for c
Rzqust [24]
The correct answer is 0.5457875.
3 0
3 years ago
Which of the following molecules is solid at room temperature?.
VashaNatasha [74]

The given option that has molecules that are solid at room temperature is; D: Saturated Fats

<h3>Molecules at room temperature </h3>

Fatty acids are organic compounds that are poorly soluble in water but soluble in organic solvents.

The two main types of fatty acids are Saturated fatty acids and Unsaturated fatty acid.

Saturated fatty acids contains no double bond in their carbon chains and as such they are solids at room temperature.

Meanwhile, Unsaturated fatty acids contains double bonds in their carbon chains and are thus liquids at room temperature.

The missing options are;

A) Both saturated and unsaturated fats

B) Cholesterol

C) Saturated fats

D) Unsaturated fats

Read more about molecules at room temperature at; brainly.com/question/17481964

8 0
2 years ago
Other questions:
  • In this food web, which group would increase in number if snakes were eliminated?
    9·2 answers
  • Which of the five measures of center (the mean, the median, the trimmed mean, the weighted mean, and the mode) can be calculated
    13·2 answers
  • The “society within us” is shaped by
    5·2 answers
  • OK GUYS THIS IS EXTREMELY HARD AND I NEED HELP <br> PLEASE HELP ME AND DONT STEAL MY POINTS
    14·1 answer
  • Select the one common noun.
    7·1 answer
  • What is the difference written in scientific notation 0. 67.
    12·1 answer
  • American sign language was first recognized as an official language in which decade.
    15·1 answer
  • Find the probability distribution of the random variable w in exercise 3.3, assuming that the coin is biased so that a head is t
    7·1 answer
  • What could help heidi reduce her test anxiety? use flash cards to study for the test eat something sugary for energy do visualiz
    14·1 answer
  • Which one of the following is the most widely used source of short-term funding that Mr. Boyd (and other small business owners)
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!