in java Write a program that determines and prints the number ofduplicate words in a sentence. Treat uppercase and lowercaseletters the same. Ignore punctuation.
Solution
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class WordFreq {
public static void main(String[] args) {
Scanner sc = newScanner(System.in);
System.out.println(“Enter sentense:”);
String str = sc.nextLine();
Map<String, Integer> map =new HashMap<>();
String words[] = str.split(“”);
for (String w : words) {
w =w.toLowerCase();
Integer n =map.get(w);
n = (n == null)? 1 : ++n;
map.put(w,n);
}
int count = 0;
for
OR
OR