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
5. How is shutter speed generally measured? What do the measurements mean?
Leokris [45]
Shutter speed<span> is </span>generally measured<span> by the scientific symbol “s”. The </span>measurement means<span> that the </span>measurements<span> in "s" is the reciprocal of the number when the denominator is put on the numerator side instead. ... Aperture is </span>measured<span> by f's.</span>
6 0
3 years ago
Read 2 more answers
The range of an area where users can access the Internet via high frequency radio signals transmitting an Internet signal from a
Alexandra [31]
A) hotspot
Bluetooth is for short distance and pan is Personal area networks (PANs) connect an individual's personal devices
8 0
3 years ago
Read 2 more answers
Which word did alexander graham bell want adopted as a telephone greeting instead of hello.
Alik [6]

Answer:

I believe it was Ahoy.

Explanation:

I could be wrong though.

7 0
2 years ago
Read 2 more answers
Which of the following items is an example of a common device for digital distribution?
docker41 [41]

Answer:

cell phone and television

Explanation:

they have computers inside of them so they are digital

4 0
2 years ago
Is anybody has to know the person delete account or not on brainly pl plz​
Oliga [24]

Ummmm.......

Nah.......

8 0
2 years ago
Other questions:
  • FTP requires confirmation that a file was successfully transmitted to a client, but it has no built-in mechanism to track this i
    7·2 answers
  • When classified data is sent over an unclassified network, what is this incident called?
    5·1 answer
  • A(n) _____ describes your core values and highest career goals. A. résumé B. objective statement C. qualifications profile D. pe
    7·2 answers
  • Instructions
    8·1 answer
  • Coding 5 - Classes The Item class is defined for you. See the bottom of the file to see how we will run the code. Define a class
    13·1 answer
  • Directions: Arrange the jumbled letters to make/form a new word. Then give a
    12·1 answer
  • Zoe wants to post something controversial online, but then she remembers that employers may look at her social media when she st
    10·1 answer
  • Synthesize (15 points)
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly. Kenny is designing a document for the employee motivation campaig
    8·1 answer
  • Use the function varimp() on the output of train() and save it to an object called imp:_____.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!