Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions StringCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Contributor Info :
// Name : Ankit Raj
// Git : https://github.com/Ankit-5087

import java.util.*;
class String2
{
public static void main(String args[])
{
Scanner sc=new Scanner (System.in);
System.out.println("PLease enter a sentence");
String str=sc.nextLine();
int l=str.length();
int nou=0,nol=0,now=0;
for(int i=0;i<l;i++)
{
char ch=str.charAt(i);
if(Character.isUpperCase(ch))
nou++;
if(Character.isLowerCase(ch))
nol++;
if(ch==' ')
now++;
}
now=now+1;
System.out.println("No. of characters="+l);
System.out.println("No. of uppercase="+nou);
System.out.println("No. of lowercase="+nol);
System.out.println("No. of words="+now);
}
}