Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I need assistance with this code. I am unsure what I did incorrectly, The lab is Word Frequencies. here is my code: import java.util.*;

Hi, I need assistance with this code.

I am unsure what I did incorrectly,

The lab is Word Frequencies. here is my code:

import java.util.*;

public class ReadWord

{

public static void main (String args[]){

int frequencies[]=new int[20];

Scanner sc=new Scanner(System.in);

String[] input=sc.nextLine().split(" ");

int n=Integer.parseInt(input[0]);

int count;

for(int i=1;i

count=0;

for(int j=0;j

if(input[i].equals(input[j+1])){

count++;

}

}

frequencies[i-1]=count;

}

for(int i=0;i

System.out.println(input[i+1]+" "+frequencies[i]);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions