Coding Problem - 2

Write a program which takes a string as input and does the following actions
* remove white spaces
* find the largest word in the text
* find number of 'x' in the given text
* find the number of integers
* find the number of words in the text
* find the number of sentences in the given input text

public class StringOperations {
        public static void main(String args[]) {
                String text = "my brother is taller than me 334 . I am always a short man , but smatter than him .";
                String word[] = text.split(" ");
                int max = 0, count = 0;
                String maxStr = "";

                // Removing whitespaces
                System.out.println("Text without space is ");
                for (int i = 0; i < word.length; i++) {
                        System.out.print(word[i]);
                }
                System.out.print("\n");

                // Largest word
                for (int i = 0; i < word.length; i++) {
                        if (max < word[i].length()) {
                                max = word[i].length();
                                maxStr = word[i];
                        }
                }
                System.out.println("The largest word is " + maxStr);

                // Finding numbers of e letters in the given text
                for (int i = 0; i < text.length(); i++) {
                        if (text.charAt(i) == 'e') {
                                count++;
                        }
                }
                System.out.println("Numbers of e in the text are: " + count);

                // Finding number of double
                int doubleCount = 0;
                for (int i = 0; i < text.length() - 1; i++) {
                        char c = text.charAt(i + 1);
                        if (text.charAt(i) == c) {
                                doubleCount++;
                        }
                }
                System.out
                                .println("Numbers of doubles in the text are: " + doubleCount);

                // Finding number of integers
                int intCount = 0;
                for (int j = 0; j < text.length(); j++) {
                        if ((text.charAt(j) >= '0' && text.charAt(j) <= '9')) {
                                intCount++;
                        }
                }
                System.out.println("Numbers of integers in the text are: " + intCount);

                // Finding number of words
                System.out.println("Number of words in the string are :"
                                + (word.length - 3));

                // Finding number of sentence
                int sencount = 0;
                for (int i = 0; i < text.length(); i++) {
                        if (text.charAt(i) == '.') {
                                sencount++;
                        }
                }
                System.out.println("Number of sentence is" + (sencount));
        }

}

Interview Questions: 

Search