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);
}
}
/**
*
* @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
Post a Comment