CODE:
import java.util.*;
class Cap
{
public static void main(String m[])
{
Scanner in=new Scanner(System.in);
String s=new String();
System.out.print("\nEnter a line: ");
s=in.nextLine();
char c;
int ct=0;
for(int i=0;i<"s.length()";i++)
{
c=s.charAt(i);
if(c>=65 && c<=90)
{
ct++;
}
}
System.out.println("\nTotal number of words start with capital letters are :"+ct);
}
}
OUTPUT:
import java.util.*;
class Cap
{
public static void main(String m[])
{
Scanner in=new Scanner(System.in);
String s=new String();
System.out.print("\nEnter a line: ");
s=in.nextLine();
char c;
int ct=0;
for(int i=0;i<"s.length()";i++)
{
c=s.charAt(i);
if(c>=65 && c<=90)
{
ct++;
}
}
System.out.println("\nTotal number of words start with capital letters are :"+ct);
}
}
OUTPUT:
No comments:
Post a Comment