Java Program to print the count of upper case letters and lower case letters in a input string.

Java Program to get count of UpperCase & LowerCase Letters in a given string.


Description:- 

In this java program we are finding the count of upper case and lower case letters present in given string.


Code:-

import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int upperCaseCount=0, lowerCaseCount=0;
        char[] charArray = str.toCharArray();
        for(int i=0;i<charArray.length;i++){
           
            if(charArray[i]>='A' && charArray[i]<='Z'){
                upperCaseCount++;
            } else if(charArray[i]>='a' && charArray[i]<='z'){
                lowerCaseCount++;
            }
        }
        System.out.println(upperCaseCount);
        System.out.println(lowerCaseCount);
    }
}


Feedback:- 

After reading this page if you have any feedback do let me know in comments; i will try to bring those things in my upcoming posts.




Comments

Popular Posts