Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.HashMap;
- import java.util.Map;
- public class nov4main {
- public static void main(String[] args) {
- int amount = 0;
- int v = 1;
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- System.out.print("Enter number of setences: ");
- //Read sentence from console
- try {
- amount = Integer.parseInt(br.readLine());
- } catch (IOException ioe) {
- System.out.println("IO error trying to read your name!");
- System.exit(1);
- }
- @SuppressWarnings("unchecked")
- Map<Character, Integer> x = new HashMap();
- String[] sentenceArray = new String[amount];
- for (int i = 0; i < amount; i++) {
- System.out.print("Enter setence: ");
- sentenceArray[i] = null;
- //Read sentence from console
- try {
- sentenceArray[i] = br.readLine();
- } catch (IOException ioe) {
- System.out.println("IO error trying to read your name!");
- System.exit(1);
- }
- sentenceArray[i].replaceAll("\\s+", ""); //remove all spaces
- System.out.println("Sentence " + (i + 1) + " Added");
- }
- for (int i = 0; i < amount; i++) {
- v = 3;
- for (int j = 0; j < sentenceArray[i].length(); j++) {
- char c = sentenceArray[i].charAt(j);
- if (x.containsKey(c)) {
- x.put(c, x.get(c) + 1);
- } else
- x.put(c, v);
- }
- System.out.println(x.size());
- if (x.size() == 26) {
- System.out.println(true);
- } else {
- System.out.println(false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement