Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.io.IOException;
- class testHello{
- public static void main(String args[]) throws IOException{
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter a string");
- String input = br.readLine();
- int upper = 0, lower = 0, blank = 0, other = 0;
- for(int i = 0; i < input.length(); i++){
- if(input.charAt(i) == ' ') blank++;
- else if(input.charAt(i) >= 65 && input.charAt(i) <= 90) upper++;
- else if(input.charAt(i) >= 97 && input.charAt(i) <= 122 ) lower++;
- else other++;
- }
- System.out.print("\nUpper: "+upper +"\nLower: " +lower +"\nBlank: " +blank);
- System.out.print("\nOther: " +other +"\nTotal: "+(upper+lower+blank+other));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement