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
Keith_Richards [23]
2 years ago
10

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 fewer than 20 words. Ex: If the input is: 5 hey hi Mark hi mark the output is: hey - 1 hi - 2 Mark - 1 hi - 2 mark - 1 Hint: Use two vectors, one vector for the strings and one vector for the frequencies.
Computers and Technology
1 answer:
tekilochka [14]2 years ago
5 0

Answer:

The following are the program to the given question:

import java.util.*;//import package for user input

public class Make  //define class Make

{

public static void main(String[] ask)  //define a main method

{

  Scanner obx = new Scanner(System.in);   //declare the Scanner class object

  int size=obx.nextInt(); //get the size of the array from the user

  int a[]=new int[size]; //declare an integer array with given size

  String word[]=new String[size]; //declare a string array with given size

  for(int i=0;i<size;i++) //set the for loop  

  word[i]=obx.next(); //get string input from the user

  for(int i=0;i<size;i++)   //iterates with the array, increase the count

  {

    for(int j=0;j<size;j++)   //defining a loop to check value

    {

      if(word[i].equals(word[j]))  //use if to check that elements of words          

      a[i]++;//increamenting array size

    }

  }

 System.out.print("\n");  //use print for break line  

  for(int i=0;i<size;i++)//set for loop to print the following result

    System.out.println(word[i]+" "+a[i]);//print value

 }

}

Output:

Please find the attachment file.

Explanation:

  • First, establish the predefined package required and instead define the main class and define the main method within the class and method.
  • Declare the scanner class object and receive an object size in the 'size' variable thru the array.
  • Next create two arrays, the integer type "a" with both the input size given and the string type "word" with the input size supplied.
  • Define the loop for which string array elements are acquired and set two to again for loop, which increases with loop iteration the integer data type array by one.
  • Lastly, set the loop for which this result is printed.

You might be interested in
What is the purpose of OPPA<br>​
aivan3 [116]

Answer:

The purpose of OPPA is to make its mandatory for companies to disclose what kind of information they will acquire from their users.

Hope it helps you!!

7 0
2 years ago
What is one problem caused by spending too much time studying at your computer? A. It increases stress and negatively affects yo
nignag [31]

Answer:

A - It increases stress and negatively affects your sleep.

Hope that helps. x

4 0
2 years ago
An engine's _______ contains the cylinder block, the cylinders, the piston, the connecting rods, and the crankshaft assemblies.
Fittoniya [83]
The answer is C.upper end

hope this helps. Have a wonderful day 
5 0
3 years ago
Read 2 more answers
True false) ther are five arrow keys on the keborad​
cluponka [151]

Answer:

false, there's only 4

Explanation:

5 0
3 years ago
_________________ uses soap or detergent to physically remove germs, dirt, and impurities from surfaces or objects.
ra1l [238]

Answer:

humans,washing mashines,dish washers

Explanation:

8 0
2 years ago
Other questions:
  • You work in a customer call center. Martin is on the phone asking about the difference between solid-state drives (SSDs), hybrid
    6·1 answer
  • rob just got a new idea for the movie he's making, and he wants to put in late hours to get it done. Which of the following stat
    10·1 answer
  • Playstation network live updates pes 2018 does it cost extra
    13·1 answer
  • Technologies designed to replace operating systems and services when they fail are called what?
    15·1 answer
  • Please help. 15 points!!!!
    8·2 answers
  • When writing code, how can printing be useful?
    15·1 answer
  • Login
    11·1 answer
  • PLZ HELP What will be the output? class num: def init (self.a): self. number = a mul* __(self. b) return self. number + b. numbe
    7·1 answer
  • Edhesive 7.6 lesson practice python
    11·1 answer
  • Selection Sort List the resulting array after each iteration of the outer loop of the selection sort algorithm. Indicate the num
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!