Java Blog

 
 
 
 public class JAVA_049
 {


    public static void main(String[] args)
    {
       String Text=\"To be or not to be, that is the question; Whether \'this\"
                  +\"nobler in the mind to suffer the sling and arrows of \"
                  +\"outrageous fortune, or to take arms against a sea of \"
                  +\"troubles, and by opposing end them?\";

       System.out.println(\"Text paragraph is : \" + Text + \"\\n\\n\");

       int spaces=0;
       int vowels=0;
       int letters=0;

       int text_length=Text.length( );

       char Ch;

       for(int i=0;i<text_length;i++)
       {
          Ch=Text.charAt(i);
          Ch=Character.toLowerCase(Ch);

          if(Ch==\'a\' || Ch==\'e\' || Ch==\'i\' || Ch==\'o\' || Ch==\'u\')
             vowels++;

          else if(Character.isLetter(Ch))
             letters++;

          else if(Character.isWhitespace(Ch))
             spaces++;
       }

       System.out.println(\"The Text contained vowels : \" + vowels + \"\\n\"
                         +\"                   spaces : \" + spaces + \"\\n\"
                         +\"                  letters : \" + letters );
    }
 }

    Related Post:
  1. CORBA program for displaying the date and time of the server machine, client machine and the difference between these two date and time

  2. Program to show an example of modifying String objects

  3. Program to show an example of overloading constructors in a class to initialize its data members

  4. Program to show the use of Conditional AND Operator (&&) in If Statements

  5. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  6. Program to declare, initialize and print an array of characters

  7. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  8. Program to copy the elements of an array into another array in reverse order and print them

  9. Program to display bank account

  10. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  11. Develop a CORBA based application for addition of two complex numbers and displaying the result on client side

  12. Program to make directory

  13. An applet program to display Vertical Color Bar

  14. File handling program to copy characters from one file to another

  15. Program to reverse the number eg given no : - 12345, output want :- 54321

  16. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  17. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  18. Program to show the use of Do-While Loop

  19. An applet program to display moving banner

  20. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

 
 
Didn't find what you were looking for? Find more on Program to show an example of getting at characters in a String