Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class alphabetCounter {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- final int LETTERS = 26;
- int[] abc = new int[LETTERS];
- System.out.println("Enter a string and end it with '*':");
- int cur = in.next().charAt(0);
- while(cur != '*')
- {
- if(cur <= 'z' && cur >= 'a')
- abc[cur - 97]++;
- cur = in.next().charAt(0);
- }
- for(int i = 0; i < LETTERS; i++)
- System.out.printf("%c - %d times\n", (i + 97), abc[i]);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment