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 meaning of SAT?​
tigry1 [53]
A standardized test taken by most high school Juniors and Seniors in order to qualify for college admittance and scholarships
4 0
3 years ago
The United States uses which source of energy to produce almost 40 percent of its
Amiraneli [1.4K]
It should be coal energy
5 0
3 years ago
The accompanying graph depicts demand at point d demand is
Georgia [21]

The accompanying graph depicts demand At point A, demand is: A)The accompanying graph depicts demand.

<h3>What did the graph depicts  at point A?</h3>

It depict the demands of goods at at that point.

The accompanying graph depicts demand At point A, demand is: A)The accompanying graph depicts demand.

CHECK THE COMPLETE QUESTION:

The accompanying graph depicts demand at point d demand:

A) unit elastic.

B) inelastic.

C) elastic.

D) perfectly elastic.

Learn more about demand on:

brainly.com/question/25220385

#SPJ1

8 0
2 years ago
philly and boston were working on a project in carpentry class. they needed to cut 5 lengths of 234 feet from a board. how long
ss7ja [257]

or 5 lengths of 234 feet to be cut from a board, the board must have a length of at least 1170 feet.

Let x represent the total length of the board so as to allow for the cutting of 5 lengths.

Since each length needed to be cut is 234 feet, hence:

x = number of lengths × feet per board

x = 5 lengths × 234 feet

x = 1170 feet

Hence for 5 lengths of 234 feet to be cut from a board, the board must have a length of at least 1170 feet.

Find out more at: brainly.com/question/18832017

6 0
3 years ago
Which animal is native to the tundra?
Sergeu [11.5K]

Answer:

the polar bear

Explanation:

the polar bear is native to tundra

8 0
3 years ago
Other questions:
  • how many criedt hours does a student typically need to complete general education requriments for a four year college
    9·1 answer
  • A light source is shining on a vertical surface or a slanted surface as shown 3 points
    10·1 answer
  • Robert Frost Mending Wall 9
    13·2 answers
  • Henry works as an Environmental Engineering Technician and Irma works as a Quality Control Analyst. Which describes their employ
    12·2 answers
  • Summer break is usually a time for vacations at the beach, afternoons at the pool, and catching up with friends. Can you imagine
    15·1 answer
  • Read the excerpt from "Morte d'Arthur" by Alfred, Lord Tennyson. Then went Sir Bedivere the second time Across the ridge, and pa
    6·2 answers
  • What is the average amount of work days in a month?
    15·1 answer
  • According to the lesson which of the following is a type of promotion.
    9·1 answer
  • Introduction to linear algebra 5th edition answers
    6·1 answer
  • Which one of the following is NOT a required component for a successful virtualization environment
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!