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
What is the velocity of flow in an asphalt channel that has a hydraulic radius of 3.404 m, length of 200 m and bed slope of 0.00
yKpoI14uk [10]

Answer:

The velocity of flow is 10.0 m/s.

Explanation:

We shall use Manning's equation to calculate the velocity of flow

Velocity of flow by manning's equation is given by

V=\frac{1}{n}R^{2/3}S^{1/2}

where

n = manning's roughness coefficient

R = hydraulic radius

S = bed slope of the channel

We know that for an asphalt channel value of manning's roughness coefficient = 0.016

Applying values in the above equation we obtain velocity of flow as

V=\frac{1}{0.016}\times 3.404^{2/3}\times 0.005^{1/2}\\\\\therefore V=10.000m/s

7 0
3 years ago
The greater the force applied to an object, the _____ the change in speed or direction of the object.
storchak [24]

Answer:

b

Explanation:

8 0
3 years ago
Which of the following answer options are your employer's responsibility?
tino4ka555 [31]

Answer:

Develop a written hazard communication program

Implement a hazard communication program

Maintain a written hazard communication program

Explanation:

To find - Which of the following answer options are your employer's responsibility?  Select all that apply.

Develop a written hazard communication program

Implement a hazard communication program

Maintain a written hazard communication program

Solution -

The correct options are -

Develop a written hazard communication program

Implement a hazard communication program

Maintain a written hazard communication program

All are the Responsibilities of an employer

Reason -

The most important duty of the employer is to stay alert and implement a correctly and efficiently written communication program related to hazards of the substances in the workplace.

He also has to maintain the program so that employees do not get affected.

3 0
3 years ago
A sinusoidal wave of frequency 420 Hz has a speed of 310 m/s. (a) How far apart are two points that differ in phase by π/8 rad?
Olin [163]

Answer:

a) Two points that differ in phase by π/8 rad are 0.0461 m apart.

b) The phase difference between two displacements at a certain point at times 1.6 ms apart is 4π/3.

Explanation:

f = 420 Hz, v = 310 m/s, λ = wavelength = ?

v = fλ

λ = v/f = 310/420 = 0.738 m

T = periodic time of the wave = 1/420 = 0.00238 s = 0.0024 s = 2.4 ms

a) Two points that differ in phase by π/8 rad

In terms of the wavelength of the wave, this is equivalent to [(π/8)/2π] fraction of a wavelength,

[(π/8)/2π] = 1/16 of a wavelength = (1/16) × 0.738 = 0.0461 m

b) two displacements at times 1.6 ms apart.

In terms of periodic time, 1.6ms is (1.6/2.4) fraction of the periodic time.

1.6/2.4 = 2/3.

This means those two points are 2/3 fraction of a periodic time away from each other.

1 complete wave = 2π rad

Points 2/3 fraction of a wave from each other will have a phase difference of 2/3 × 2π = 4π/3.

8 0
4 years ago
The uniform slender rod has a mass m.
Nikolay [14]

Answer: 3/2mg

Explanation:

Express the moment equation about point B

MB = (M K)B

-mg cosθ (L/6) = m[α(L/6)](L/6) – (1/12mL^2 )α

α = 3g/2L cosθ

express the force equation along n and t axes.

Ft = m (aG)t

mg cosθ – Bt = m [(3g/2L cos) (L/6)]

Bt = ¾ mg cosθ

Fn = m (aG)n

Bn -mgsinθ = m[ω^2 (L/6)]

Bn =1/6 mω^2 L + mgsinθ

Calculate the angular velocity of the rod

ω = √(3g/L sinθ)

when θ = 90°, calculate the values of Bt and Bn

Bt =3/4 mg cos90°

= 0

Bn =1/6m (3g/L)(L) + mg sin (9o°)

= 3/2mg

Hence, the reactive force at A is,

FA = √(02 +(3/2mg)^2

= 3/2 mg

The magnitude of the reactive force exerted on it by pin B when θ = 90° is 3/2mg

6 0
3 years ago
Other questions:
  • Air is compressed adiabatically from p1 1 bar, T1 300 K to p2 15 bar, v2 0.1227 m3 /kg. The air is then cooled at constant volum
    13·1 answer
  • For a heat pump, COP&lt;1. a) True b) False
    11·1 answer
  • Write a SELECT statement that returns the same result set as this SELECT statement. Substitute a subquery in a WHERE clause for
    10·1 answer
  • According to the decreasing order of toughness. list the following materials (note: the steels are assumed to have no cold work
    6·1 answer
  • Find the mathematical equation for SF distribution and BM diagram for the beam shown in figure 1.​
    10·1 answer
  • The density of a fluid is given by the empirical equation rho 70:5 exp 8:27 107 P where rho is density (lbm/ft3 ) and P is press
    6·1 answer
  • The viscosity of all liquids decreases as the temperature is a) Increased b) decreased c) maintained constant d) fluctuating e)
    12·1 answer
  • How do i open a door<br> please i've been trapped in this room for ages
    9·1 answer
  • How much energy in joule is added to a 12 g of sample of aluminum (c=0.897 J/g ◦C) to raise the temperature from 20 ◦C to 45 ◦C?
    14·1 answer
  • You need to lift a 2012 toyota highlander and haven't done so in a while. which of these are reliable sources for checking the c
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!