Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class CapitalLetterCounter {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- int listSize;
- int capitalCounter = 0;
- char ch;
- System.out.println("How long is your list of characters?");
- listSize = in.nextInt();
- System.out.println("Enter characters:");
- for (int i = 0; i < listSize; i++)
- {
- ch = in.next().charAt(0);
- if(ch >= 'A' && ch <= 'Z')
- capitalCounter++;
- }
- System.out.printf("The number of characters that are capital letters in the English alphabet is %d.", capitalCounter);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement