Hi, I need to write a word count program that does not produce any duplicates ir
ID: 3647190 • Letter: H
Question
Hi, I need to write a word count program that does not produce any duplicates irregardless of any specific punctuation. The code that I have is as follows.import. java.util.*;
public class WordCount
{
public static void main(String[]args)
{
final int Lines=6;
Scanner in=new Scanner (System.in)
String paragraph = "";
System.out.println( "Please input"+ Lines + "lines of text.");
for (int i=0; i < Lines; i+=1)
{
paragraph=paragraph+""+in.nextLine()
}
System.out.println(paragraph);
System.out.println(paragraph.length());
String word=""
int WordCount=0
for (int i=0; i<paragraph.length()-1; i+=1)
{
if (paragraph.charAt(i) !==' ')
{
word= ;
if(paragraph.charAt(i+1)==' ')
{
System.out.println(word);
wordCount +=1
word="";
}
}
}
}
}
Explanation / Answer
Mayy be this change in code is helpful for you import. java.util.*; public class WordCount { public static void main(String[]args) { final int Lines=6; Scanner in=new Scanner (System.in) String paragraph = ""; System.out.println( "Please input"+ Lines + "lines of text."); for (int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.