5th sem OOPJ Write a program to count the number of words that start with capital letters.

import java.io.*;

/**
 *
 * @author Yash
 */

class pra6{
    public static void main(String arg[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        int num=0;
        System.out.println("Write a line :");
        String str  = br.readLine();
       
        for(int i=0;i<str.length();i++){
            if(Character.isUpperCase(str.charAt(i))){
             num++;
            }
        }
        System.out.println("The Number of Upper case is : "+num);
    }  
}

Comments

Popular posts from this blog

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

SQL Lab 3

SQL Lab1: Create a Database Table for DayCare