Friday 10 July 2015

Write a program to count the number of words that start with capital letters


  
 

import java.util.Scanner;

public class Program_6 {

    public static void main(String[] args) {

        int count = 0;
        Scanner scan = new Scanner(System.in);
        String str = scan.next();

        for (int i = 0; i < str.length(); i++) {
            if (Character.isUpperCase(str.charAt(i))) {
                count++;
            }
        }
        System.out.println("No of Capital Letters:" + count);
    }
}

  

2 comments: