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
Alla [95]
4 years ago
7

Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with a

n integer indicating the number of words that follow. Assume that the list will always contain less than 20 words.
Engineering
1 answer:
Romashka [77]4 years ago
7 0

Answer:

import java.util.HashMap;

import java.util.Map;

import java.util.Scanner;

public class FrequencyOfWords

{

   public static void main(String[] args)

   {

       Scanner in = new Scanner(System.in);

 

       System.out.println("Enter the integer indicating the number of words");

 

       int n = in.nextInt();

       System.out.println("Enter the string");

       

     

       String[] words = new String[n];

       

       for(int i = 0; i < n; ++i)

       {

           words[i] = in.next();

       }

       Map<String, Integer> map = new HashMap<>();

       

       for(int i = 0; i < n; ++i)

       {

           if(!map.containsKey(words[i]))

           {

               map.put(words[i], 0);

           }

           map.put(words[i], map.get(words[i])+1);

       }

       for(Map.Entry<String, Integer> entry : map.entrySet())

       {

           System.out.println(entry.getKey() + " " + entry.getValue());

       }

   }

}

You might be interested in
On a ruler or tape measure, what is the distance from 1 3/8 to 3 1/2?​
Juli2301 [7.4K]

Answer:

Distance=√(x2−x1)2+(y2−y1)2 Distance = ( x 2 - x 1 ) 2 + ( y 2 - y 1 ) 2.

Explanation:

So for this the distance formula is

= distance

(x_1, y_1) = coordinates of the first point

(x_2, y_2) = coordinates of the second point

7 0
3 years ago
True power can only be measured across what?
loris [4]

Answer: mets

Explanation: meets are good

6 0
3 years ago
Read 2 more answers
Consider incompressible flow in a circular channel. Derive general expressions for Reynolds number in terms of (a) volume flow r
Georgia [21]

Answer:

a) Re = \frac{4\cdot \rho \cdot Q}{\pi\cdot \mu\cdot D}, b) Re = \frac{4\cdot \dot m}{\pi\cdot \mu\cdot D}, c) 1600

Explanation:

a) The Reynolds Number is modelled after the following formula:

Re = \frac{\rho \cdot v \cdot D}{\mu}

Where:

\rho - Fluid density.

\mu - Dynamics viscosity.

D - Diameter of the tube.

v - Fluid speed.

The formula can be expanded as follows:

Re = \frac{\rho \cdot \frac{4Q}{\pi\cdot D^{2}}\cdot D }{\mu}

Re = \frac{4\cdot \rho \cdot Q}{\pi\cdot \mu\cdot D}

b) The Reynolds Number has this alternative form:

Re = \frac{4\cdot \dot m}{\pi\cdot \mu\cdot D}

c) Since the diameter is the same than original tube, the Reynolds number is 1600.

8 0
3 years ago
The yield strength of mild steel is 150 MPa for an average grain diameter of 0.038 mm ; yield strength is 250 MPa for average gr
djyliett [7]

Answer:

Explanation:

Hall-Petch equation provides direct relations between the strength of the material and the grain size:

σ=σ0+k/√d , where d- grain size, σ- strength for the given gran size, σ0 and k are the equation constants.

As in this problem, we don't know the constants of the equation, but we know two properties of the material, we are able to find them from the system of equations:

σ1=σ0+k/√d1

σ2=σ0+k/√d2 , where 1 and 2 represent 150MPa and 250MPa strength of the steel.

Note, that for the given problem, there is no need to convert units to SI, as constants can have any units, which are convenient for us.

From the system of equations calculations, we can find constant: σ0=55.196 MPa, k=18.48 MPa*mm^(0.5)

Now we are able to calculate strength for the grain diameter of 0.004 mm:

σ=55.196+18.48/(√0.004)=347.39 MPa

The strength of the steel with the grais size of 0.004 mm is 347.39 MPa.

6 0
4 years ago
A field sample of an unconfined aquifer is packed in a test cylinder. The length and diameter of the cylinder are 50 cm and 6 cm
Orlov [11]

Answer:

0.09cm/sec

Explanation:

We are going to describe Hydraulic conductivity as a measure of the ease with which water flows through sediments, determining renewal rates of water, dissolved gases, and nutrients.

See attachment for a detailed solution.

7 0
3 years ago
Other questions:
  • How do i get my camera to work in the app, i just got a new phone and it won’t pull up the camera
    14·1 answer
  • A 1-m long, thin symmetric airfoil is placed at a free stream. Calculate the drag force for the wind speed of 150 m/s. Assume th
    7·1 answer
  • A spacecraft starts in elliptical orbit JK (red solid curve) around some planet and transfers to elliptical orbit MN (blue solid
    7·1 answer
  • You are ordering steel cable for a 250 foot long zip-line you are building in your back yard. The cable can be ordered in diamet
    6·2 answers
  • Write a program to sort the student’s names (ascending order), calculate students’ average test scores and letter grades (Use th
    13·1 answer
  • Are there specific building code requirements for the installation of specialized water-based fire protection systems?
    10·1 answer
  • A square (12.5 mm × 12.5 mm) silicon chip is insulated on one side and cooled on the opposite side by atmospheric air in paralle
    14·1 answer
  • The wall of an oven used to cure plastic parts is of thickness L = 0.05 m and is exposed to large surroundings and air at its ou
    14·1 answer
  • In a residence, the control of a room's baseboard electric resistance heating system would be accomplished automatically using a
    12·2 answers
  • Question 2
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!