Require
•
The program must read data from the keyboard 10 times. IT'S OK
•
The program should display text on the screen. WRONG
•
The displayed text should contain 26 lines. WRONG
•
Each line of output should contain a letter of the English alphabet, a space, and the number of times the letter was found in the entered lines. WRONG
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String abc = "abcdefghijklmnopqrstuvwxyz";
char[] abcArray = abc.toCharArray();
ArrayList<Character> alphabet = new ArrayList<>();
for (char letter : abcArray) {
alphabet.add(letter);
}
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s.toLowerCase());
}
Map<Character, Integer> map = new HashMap<>();
for(char c:abcArray){
map.put(c, 0);
}
for(String s: list){
for(char l: s.toCharArray()){
int a = map.get(l);
map.put(l, a+1);
}
}
for(char c: abcArray){
System.out.println(c+" "+map.get(c));
}
}
}