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
This sample of air at 35°C and 60% relative humidity holds grams/cubic meter of water vapor.
natulia [17]

Answer:

  • <u>60%</u>

Explanation:

The first part of the text is incomplete but it is not needed to answer the question, which is what is the<em> relative humidity</em> of a <em>sample of air </em>at <em>40ºC</em>, if it can hold a <em>maximum of 50 grams/cubic meter</em>, and it currently holds <em>30 grams/cubic meter.</em>

The maximum amount of water that a sample of air can hold  depends on the temperature.

Relative humidity is the percentage ratio of water actually in the air relative to the maximum amount it can hold, at the given temperature.

  • % relative humidity =

             = (water in the air) / (maximum amount the air can hold) × 100

It is stated that the maximum amount the sample of air can contain is 50g/m³, and it currently holds 30g/m³, then the relative humidity is:

  • % relative humidity = (30g/m³ / 50gm³) × 100 = 60% ← answer

7 0
3 years ago
Read 2 more answers
A scientist has invented a pill that can replace sleep
zysi [14]

Answer:

<h2><u> Modafinil</u></h2>

Explanation:

Scientists are hoping to build on the success of the drug <u>Modafinil</u>, a stimulant launched seven years ago which allows people to wake up refreshed after four hours of sleep. It does sound far-fetched since we have such little understanding of sleep and dreams but anything is possible.

<em>Hope this helps :) </em>

<em> Pls mark brainliest :3 </em>

<em> And have an amazing day <3</em>

3 0
3 years ago
Many flowering plants have very colorful petals like the lily seen here. What is the main purpose of these colorful petals?
alukav5142 [94]
Petals are modified leaves that surround the reproductive parts of flowers, They are often brightly colored or unusually shaped to attract pollinators.
4 0
3 years ago
Read 2 more answers
Rewrite each of the following sentences adding an adverb to modify the verb.
VladimirAG [237]

Answer:

gotta take a picture

Explanation:

send pics so people can see what sentences you're talking about ;0

4 0
3 years ago
a city of punjab has a 15 percent chance of wet weather on any given day. what is the probability that it will take a week for i
Marrrta [24]

Answer:

h

Explanation:

h

4 0
3 years ago
Other questions:
  • What is the pH scale? a. It is a measure of the acidity in a solution. c. It is a measure of the amount of pollution in the air.
    6·2 answers
  • For a child categorized as having a slow to warm temperament as identified by Thomas and Chess, caregivers should...
    12·1 answer
  • ...................................................................................
    5·2 answers
  • Which answer is an example of a pull changing motion
    7·1 answer
  • What does "This change" refer to? Choose the word or phrase that completes the ideas.
    9·2 answers
  • Who is cleopatra in the caesars sportsbook commercial.
    12·1 answer
  • A survey asks students who walk or ride a bike to school.
    12·1 answer
  • School x and school y.
    10·1 answer
  • Reorder the sentence parts to state the ideas more clearly.
    12·1 answer
  • What important decisions did the characters make in the story “Relationship” by Jhoanna Lynn Cruz
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!