Write a java program to calculate product of count of uppercase and lowercase letters


Program
import java.util.Scanner; public class minmax { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the String"); String s = sc.nextLine(); int upper = 0; int lower = 0; int i; if (s.matches("[a-zA-Z]+")) { for (i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c >= 'A' && c <= 'Z') { upper++; } if (c >= 'a' && c <= 'z') { lower++; } } System.out.println(upper * lower); } else { System.out.println("Invalid String"); } } }
Input
Output