Advertisement
AlimusSifar

Alayna and Strings - Toph.co - Brute Force

Apr 23rd, 2020
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class solution {    
  3.     public static void main(String[] args) {
  4.         Scanner sc = new Scanner(System.in);
  5.         String str = sc.nextLine();
  6.  
  7.         int capital = 0, small = 0;
  8.         for (int i = 0; i < str.length(); i++) {
  9.             if ((int) str.charAt(i) >= 65 && (int) str.charAt(i) <= 90) {
  10.                 capital++;
  11.             } else if ((int) str.charAt(i) >= 97 && (int) str.charAt(i) <= 122) {
  12.                 small++;
  13.             }
  14.         }
  15.         System.out.println(capital + " " + small);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement