Write a program to input a String str from user and print count of uppercase and lowercase letters in it.
import java.lang.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
// int n = scn.nextInt();
String str = scn.nextLine();
int n = str.length();
int upper = 0; int lower = 0;
for (int i =0; i < n; i++)
{
char ch = str.charAt(i);
if (ch>='A' && ch <='Z')
{
upper++;
}
else if (ch >= 'a' && ch <='z')
{
lower++;
}
}
System.out.println(upper);
System.out.println(lower);
}
}
Leave a comment