Counting vowels question

Have the user input a sentence. Count the vowels and output your findings. Vowels are comprised of the letters: a e i o u. Remember that a vowel can be in upper case or lower case. (e.g., A or a)
Your program could look as follows:
im very confused..

What is your question?  It looks almost as if you are submitting school assignments for people to solve for you here.
If you are looking for an idea of how to code this, one way would be to create an array that contains the vowels and loop thru the sentence (String) and test each character to see if it is in the array (use the Array.indexOf() method).  Keep a count of how many match what is in the array.

Similar Messages

  • Help Counting Vowels and Consonants using a class

    I'm currently working on a class project where I need take a user inputed string and count how many vowels and/or consonants are in the String at the user discretion. I have the main logic program working fine. However, the trouble I'm running into is how to take the string the user inputed and pass that data into the class method for counting.
    Here is the code for the program:
    package vowelsandconsonants;
    import java.util.Scanner;
    public class VowelConsCounter {
        public static void main(String[] args) {
            String input; //User input
            char selection; //Menu selection
            //Create a Scanner object for keyboard input.
            Scanner keyboard = new Scanner(System.in);
            //Get the string to start out with.
            System.out.print("Enter a string: ");
            input = keyboard.nextLine();
            //Create a VowelCons object.
            VowelCons vc = new VowelCons(input);
            do {
                // Display the menu and get the user's selection.
                selection = getMenuSelection();
                // Act on the selection
                switch (Character.toLowerCase(selection)) {
                    case 'a':
                        System.out.println("\nNumber of Vowels: " +
                                vc.getNumVowels());
                        break;
                    case 'b':
                        System.out.println("\nNumber of consonats: " +
                                vc.getNumConsonants());
                        break;
                    case 'c':
                        System.out.println("\nNumber of Vowels: " +
                                vc.getNumVowels());
                        System.out.println("Number of consonants: " +
                                vc.getNumConsonants());
                        break;
                    case 'd':
                        System.out.print("Enter a string: ");
                        input = keyboard.nextLine();
                        vc = new VowelCons(input);
            } while (Character.toLowerCase(selection) != 'e');
         * The getMenuSelection method displays the menu and gets the user's choice.
        public static char getMenuSelection() {
            String input;  //To hold keyboard input
            char selection;  // The user's selection
            //Create a Scanner object for keyboard input.
            Scanner keyboard = new Scanner(System.in);
            //Display the menu.
            System.out.println("a) Count the number of vowels in the string.");
            System.out.println("b) Count the number of consonants in the string.");
            System.out.println("c) Count both the vowels and consonants in the string.");
            System.out.println("d) Enter another string.");
            System.out.println("e) Exit the program.");
            //Get the user's selection
            input = keyboard.nextLine();
            selection = input.charAt(0);
            //Validate the input
            while (Character.toLowerCase(selection) < 'a' ||
                    Character.toLowerCase(selection) > 'e') {
                System.out.print("Only enter a,b,c,d or e:");
                input = keyboard.nextLine();
                selection = input.charAt(0);
            return selection;
    class VowelCons {
        private char[] vowels;
        private char[] consonants;
        private int numVowels = 0;
        private int numCons = 0;
        public VowelCons(String str) {
        public int getNumVowels() {
            return numVowels;
        public int getNumConsonants() {
            return numCons;
        private void countVowelsAndCons() {
            for (int i = 0; i < total; i++) {
                char ch = inputString.charAt(i);
                if ((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U')) {
                    numVowels++;
                } else if (Character.isLetter(ch)) {
                    numCons++;
    }The UML given to me by my instructor calls for the counting method to be private. Being that I'm not too familiar with Java syntax I did not know if that may cause a problem with passing the user's input into that method.

    Well the only compilers i get are due to the code:
    private void countVowelsAndCons() {
            for (int i = 0; i < total; i++) {
                char ch = inputString.charAt(i);
                if ((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U')) {
                    numVowels++;
                } else if (Character.isLetter(ch)) {
                    numCons++;
        }However, that is due to the fact that i have no data for those variables to use. I'm pretty much stuck on how to get the string the user inputs into that method shown above so the code can perform the task of counting the vowels and consonants.
    If i comment out the code within that function the program compiles and will allow me to enter the string and use the options but since i can't figure out how to pass the input to the counting method the program returns 0 for everything.

  • Counting vowels, upper and lower case.

    Hi,
    was wondering if anyone knew how to fix this snippet of code. It keeps on producing really weird results. I'm trying to count the number of vowels a,A,e,E,i,I,o,O,u,U in a string entered by the user
    here is my code....
    theString = str5.nextToken();
    if(theString.equalsIgnoreCase("a") || theString.equalsIgnoreCase("e") || theString.equalsIgnoreCase("i") || theString.equalsIgnoreCase("o") || theString.equalsIgnoreCase("u") )
    num++;
    //my code doesn't seem to count uppercase vowels. I've spent a few days on it already -- I'm getting
    a headache. Any help would be greatly appreciated.
    Thanks.          
         

    One of the many ways
    class VowelCounter
      public static void main(String args[])
        String sentence = "What would the code be to individually read"+
                     " in the vowels from a string,and then output the"+
              " results in something resembling the following format";
        String vowels[] = {"a","e","i","o","u"};
        int count, total = sentence.length();;
        for(int x = 0; x < vowels.length; x++)
          sentence = sentence.toLowerCase().replaceAll(vowels[x],"");
          count = total - sentence.length();
          total -= count;
          System.out.println("Total of "+vowels[x]+"'s = "+count);
        System.out.println(total+ " characters remain (inc. spaces)");
        System.exit(0);
    }

  • Trouble Counting Vowels and Consonants

    Hey I am trying to create a GUI that has three text fields, one for typing letters into it, the other two counts the vowels and consonants. However, I can't get the code to properly spit out any numbers and whenever I type in letters I get an exception: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class GUI extends JFrame implements KeyListener {
         public int numberOfConsonents = 0;
         public int numberOfVowels = 0;
         public JTextField jtf1;
         public JTextField jtf2;
         public JTextField jtf3;
         public JLabel jl3;
         public JLabel jl2;
         public GUI(){
         JTextField jtf1;
         JTextField jtf2;
         JTextField jtf3;
         jtf1 = new JTextField(20);
         jtf1.addKeyListener(this);
         jtf2 = new JTextField(5);
         jtf3 = new JTextField(5);
         jl2 = new JLabel("Vowels");
         jl3 = new JLabel("Consonants");
         jtf2.setEditable(false);
         jtf3.setEditable(false);
         getContentPane().setLayout(new GridLayout(2,3));
         getContentPane().add(jtf1);
         getContentPane().add(jl2);
         getContentPane().add(jtf2);
         getContentPane().add(jl3);
         getContentPane().add(jtf3);
         public void keyPressed (KeyEvent ke){
              char c = ke.getKeyChar();
              if (Character.isLetter(c)){
                   c = Character.toLowerCase(c);
                   if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
                        numberOfVowels++;
                        jtf3.setText(""+numberOfVowels);
                   else{
                        numberOfConsonents++;
                        jtf2.setText(""+numberOfConsonents);
              validate();
    //      not used
         public void keyReleased (KeyEvent ke){
         // not used
         public void keyTyped (KeyEvent ke){
         public static void main(String args[]){
              GUI gui = new GUI();
              gui.pack();
              gui.setVisible(true);
              gui.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    In your constructor, don't re-declare the JTextFields. Essentially...
         public GUI(){
         jtf1 = new JTextField(20);
         jtf1.addKeyListener(this);
         jtf2 = new JTextField(5);
         jtf3 = new JTextField(5);
         jl2 = new JLabel("Vowels");
         jl3 = new JLabel("Consonants");
         jtf2.setEditable(false);
         jtf3.setEditable(false);
         getContentPane().setLayout(new GridLayout(2,3));
         getContentPane().add(jtf1);
         getContentPane().add(jl2);
         getContentPane().add(jtf2);
         getContentPane().add(jl3);
         getContentPane().add(jtf3);
         }The reason it's making an error is because you never construct the GLOBAL JTextFields. To access a JTextField globally, if you already have a JTextField with the same name in some method, you have to use this.theNameOfTheThing .

  • Parent - child table issue wrt to count - SQL question

    I have a scenario:
    There are 2 tables (parent and child). lets say, case summary table and task level dimension table.
    for every case id in case summary table, there would be multiple tasks in task level dim table with a flag indicator set to 1 for all tasks.
    but while counting the number of cases active with flag indicator 1 (ofcourse when joining case summary table with task dimension table), for a case id only 1 instance of task needs to be accounted (even though it has more than one task , for counting active cases, the flag ind corresponding to a task in a case if set to 1 , then the case is considered active)..but while joining and taking count of case ids with flag indicator as 1, you get the count of every task row of a case which is incorrect logically. how to discard the rest of child records of a case in child table (task dimension table)?
    I am not sure how to achieve this in sql query
    Kindly help!
    Case summary table
    case id, busininess_unit, agent_name
    1001, admin, Ram
    1002, Finance, Sam
    task table
    case id, task_id,task_name, flag_indicator
    1001, 1, 'New', 1
    1001,2, 'Open',1
    1001,3,'In progress',1
    1002, 4, 'New', 1
    (In fact task_id is not a big deal... even you can assume task id doesn't exist..only task name ... )
    now my question... if my query should get the current active cases (ind=1); as per above it should essentially give 2... but my query gives me 4..you know the reason why.. but how do i get the correct count?
    Thanks!

    may be you need just this:
    select count(distinct case_id) from task
    where indicator = 1;
    If this is not what you are looking for, please elaborate and tell us the expected output and rest of the details as mentioned in FAQ Re: 2. How do I ask a question on the forums?:

  • Counting vowels in a word.

    I am to write a recursive program that counts the number of vowels in a given String. So far, this is what I have:
    public static int CountVowels( String s )
    if ( s.length() == 0 )
      return 0;
    else
      if ( (s.substring(0,1) == "a") || (s.substring(0,1) == "e") || (s.substring(0,1) == "i") || (s.substring(0,1) == "o") || (s.substring(0,1) == "u") || (s.substring(0,1) == "A") || (s.substring(0,1) == "E") || (s.substring(0,1) == "I") || (s.substring(0,1) == "O") || (s.substring(0,1) == "U") )
       return 1 + CountVowels(s.substring(0,1));
      else
       return 0 + CountVowels(s.substring(0,1));
    }

    Norm_Sea_3 wrote:
    I am to write a recursive program that counts the number of vowels in a given String. So far, this is what I haveIf you are looking for a recursive solution then you can use this
    public static int CountVowels( String s )
      if ( s.length() == 0 )
       return 0;
      else
       char x=charAt(0);
       if ( x == "a"|| x == "e" || x == "i" || x == "o" || x == "u" || x == "A" || x == "E" || x == "I" || x == "O"|| x == "U" )
        return 1 + CountVowels(s.substring(1,s.length()));
       else
        return 0 + CountVowels(s.substring(1,s.length()));
    }

  • Counting Vowels and Consonants...

    Hellos All,
    I have the following
    import java.util.Scanner;
    public class r3
    public static void main(String[] args)
    //declare variables
    String userInput, workString = "";
    int stringLength;
    int numberVowels = 0;
    char userChoice;
    Scanner keyboard = new Scanner(System.in);
    char[] vowelArray = {'a', 'e', 'i', 'o', 'u'};
    boolean enterAString;
    System.out.println("Would you like to enter a string");
    enterAString = keyboard.nextBoolean();
    //user input
    while(enterAString)
    {//begin loop
    System.out.println("please enter a string");
    userInput = keyboard.nextLine();
    userInput = userInput.toLowerCase();
    stringLength = userInput.length();
    for(int i = 0; i < stringLength; ++i)
    if((int)userInput.charAt(i) >= 97 && (int)userInput.charAt(i) <=122)
    workString = workString + userInput.charAt(i);
    for(int i = 0; i < stringLength; ++i)
    if(userInput.charAt(i) >= 'a' && userInput.charAt(i) <= 'z')
    workString = workString + userInput.charAt(i);
    System.out.println(workString);
    System.out.println("Please select\n"
    +"a for number of vowels\n"
    +"b for number of consonents\n"
    +"c for number of vowels and consonents\n"
    +"d to enter another string\n"
    +"e to exit\n");
    userChoice = ((keyboard.nextLine()).toLowerCase()).charAt(0);
    System.out.println(userChoice);
    //determin number of vowels
    for(int i = 0; i < workString.length(); ++i)
    for(int j = 0; j < vowelArray.length; ++j)
    if(workString.charAt(i) == vowelArray[j])
    numberVowels++;
    switch(userChoice)
    case 'a':
    System.out.println("The number of vowels is: " + numberVowels);
    break;
    case 'b':
    System.out.println("The number of consonents is: " + (workString.length() - numberVowels));
    break;
    case 'c':
    System.out.println("The number of vowels and consonents is: " + workString.length());
    break;
    case 'd':
    break;
    case 'e':
    enterAString = false;
    break;
    default:
    System.out.println("Invalid input. Goodby.");
    }//end switch
    }//end loop
    System.out.println("Thanks for playing");
    }//end main
    }//end classSo far it somewhat works fine, but for the number of consonents when printed. The number printed out is not equal to the string input by the user. The bigger the string gets the bigger the difference in the amount of consonants.
    any help would be appretiated thanks

    you can do this very easily by using 2 replace alls.
    String userInput = ...
    String pureText = (userInput.toLowerCase()).replaceAll("[^a-z]", "");
    String vowels = pureText.replaceAll("[^aeiou]", "");
    int vowelCount = vowels.length();
    int consonantCount = pureText.length() - vowelCount;

  • How to print photo with Count Tool markers visible? [was: count tool question]

    I am doing a lab report that requires me to count a large number of objects in a photo using the count tool, i need to print out that photo with the count markers visible to show the instructor, however i cant seem to be able to do that. is it possble. Thanks

    I don't have a good answer for you, If you under a deadline to finish the project, you can always view the image at 100% and do a series of screen captures, then piece the image back together. Not the idea solution, but it should work.

  • Counter with question

    Hi,
    I hav e an assignemtn to finish for college. have it mostly done but 1 thing.
    what i need to do is creat a loop (im thinking if else) that will repeat the program to allow uptas of the info held.
    the program accepts in info and does what it need then ends.,
    now i am familier with C++ thats why i say an if else loop. but im not sure how to enter it into Java.
    and if i do that will the program just re run or rerun and hold the old info in it?
    and sujestions?
    thanks

    sorry here is the offending code.
    and its working better than it was. it accepts all input for the first run. but on the second run, it wont let me enter anything for the first question.
    im sure its just something simple im missing, but i cant see it.
    import java.util.Scanner;
    public class InvoiceRun
    public static void main( String args[])
    Scanner input = new Scanner( System.in );
    Invoice invoice = new Invoice();
              int result = 0;
              int i = 0;
              while (i == 0)
              System.out.println("\n\n" +
                                  "***********************************************" +
    "********************************* \n\n");
              System.out.println("\t\t\t Details of Invoice \n\t\t For Killester Hardware store\n\n" +
                                  "***********************************************" +
    "********************************* \n\n");
    System.out.println("- Sku Number :. ");
    String in = input.nextLine();
    invoice.setNumber(in);
    System.out.println("- Part Description :. ");
    in = input.nextLine();
    invoice.setDescription(in);
    System.out.println("- Quantity of Parts :. ");
    in = input.nextLine();
    invoice.setQuantity(Integer.parseInt(in));
    System.out.println("- Price Per Part :. ");
    in = input.nextLine();
    invoice.setpricePerItem(Double.parseDouble(in));
    System.out.println("***********************************************" +
    "********************************* \n\n" +
    "\t\t\t\t Invoice ::::\n\n" +
                        "***********************************************" +
    "********************************* \n\n" +
    "\t\t\t SKU Number :: " + invoice.getNumber() + "\n" +
    "\t\t\t Item :: " + invoice.getDescription() + "\n" +
    "\t\t\t Amount :: " + invoice.getQuantity() + "\n" +
    "\t\t\t Price Per :: " + invoice.getpricePerItem() +
    "\n\n***********************************************" +
    "********************************* \n\n" +
    "\t\t\t\t Invoice Total :: " + invoice.getTotal()
    + "\n***********************************************" +
    System.out.print ("Do you want to enter a new Invoice? \n Press 0 for Yes \n Press 1 for no \n\n then press enter \n\n");
    result = input.nextInt();
    if (result == 1)
         i=1;
    }

  • Rating - Play count totals question ...

    Hi,
    I'd like to transfer the Rating & Play count totals to another computer (that has hopefully the same play list).
    How do I do this?
    Thanks.

    As you probably know, the rating and playcount are not stored in the song file itself; they are stored in the library and will be lost if you move the songs separately from the entire library.
    So, to preserve them, first consolidate your library (if it isn't already) using the command File > Library > Organize Library... > Consolidate Files, and then copy the entire iTunes folder to the new machine.

  • Count booking question

    Hello in a booking table iwth fields
    id , room_id , start_date , end_date
    i want to find how many days eatch month or in a from to date a room is booked group by room.
    Any ideas ?
    Regards
    Aris

    with parameters as
      select to_date('&param_start_date', 'YYYYMMDD') as start_date, to_date('&param_end_date', 'YYYYMMDD') as end_date from dual
    booking as
      select 1 as id, 1 as room_id, to_date('20091101', 'YYYYMMDD') as start_date, to_date('20091110', 'YYYYMMDD') as end_date from dual union all
      select 2 as id, 1 as room_id, to_date('20091115', 'YYYYMMDD') as start_date, to_date('20091118', 'YYYYMMDD') as end_date from dual union all
      select 3 as id, 2 as room_id, to_date('20091103', 'YYYYMMDD') as start_date, to_date('20091108', 'YYYYMMDD') as end_date from dual
    select booking.room_id,
           sum(least(booking.end_date, parameters.end_date) - greatest(booking.start_date, parameters.start_date) + 1) as days
    from booking, parameters
    where booking.start_date between parameters.start_date and parameters.end_date
    or booking.end_date between parameters.start_date and parameters.end_date
    or (booking.start_date < parameters.start_date and booking.end_date > parameters.end_date)
    group by booking.room_id
    Enter value for param_start_date: 20091101
    Enter value for param_end_date: 20091130
    old   3:   select to_date('&param_start_date', 'YYYYMMDD') as start_date, to_date('&param_end_date',
    new   3:   select to_date('20091101', 'YYYYMMDD') as start_date, to_date('20091130', 'YYYYMMDD') as
       ROOM_ID       DAYS
             1         14
             2          6
    SQL> /
    Enter value for param_start_date: 20091105
    Enter value for param_end_date: 20091109
    old   3:   select to_date('&param_start_date', 'YYYYMMDD') as start_date, to_date('&param_end_date',
    new   3:   select to_date('20091105', 'YYYYMMDD') as start_date, to_date('20091109', 'YYYYMMDD') as
       ROOM_ID       DAYS
             1          5
             2          4

  • Image count (simple question, cant find the option)

    Hello,
    it is simple, but ain't easy to find in preferences:
    I used to have the number of images (pictures) for every folder
    under Projects in the left pane
    Now they disappeared and I can't find the option to get them back
    Some can help me ?
    Thanks

    It is in the Preferences>Appearance. Near the bottom is a checkbox to Show number of versions for projects and albums.
    I agree about finding it in any index, couldn't come up with the right word.
    Bill

  • Spamtrainer -f & X-Spam-***: Question

    I switched to a Mac Pro Intel as my server a few months ago. I have been working out the kinks. I was moving from a Tiger Server install on a PowerMac G5. I had all the stuff for amavis, clamav, & spamassassin fixed on that install. I missed something since I have 2 .spamassassin directories and no symlink in /var/clamav/ or /var/amavis/. I have been running the nightly cron job as setup by Spamtrainer 1.2.7. I just updated to 1.5.7.
    So since I have been running this I do have a bayes DB.
    sudo su - clamav -c "sa-learn --dump magic"
    0.000 0 3 0 non-token data: bayes db version
    0.000 0 14767 0 non-token data: nspam
    0.000 0 1402 0 non-token data: nham
    0.000 0 181092 0 non-token data: ntokens
    0.000 0 1165964162 0 non-token data: oldest atime
    0.000 0 1170363924 0 non-token data: newest atime
    0.000 0 1170396013 0 non-token data: last journal sync atime
    0.000 0 1170396020 0 non-token data: last expiry atime
    0.000 0 2764800 0 non-token data: last expire atime delta
    0.000 0 12699 0 non-token data: last expire reduction count
    First question is if I run spamtrainer -f will this delete the current DB?
    If yes how do I combine the 2 directories before making the symlink?
    What directory does spamtrainer -b backup /var/amavis/ or /var/clamav/?
    /var/amavis/.spamassassin root# ls -loa
    total 61896
    -rw------- 1 clamav clamav - 20983808 Feb 2 17:43 auto-whitelist
    -rw------- 1 clamav clamav - 95472 Feb 2 17:43 bayes_journal
    -rw------- 1 clamav clamav - 5218304 Feb 2 17:43 bayes_seen
    -rw------- 1 clamav clamav - 5390336 Feb 2 17:43 bayes_toks
    /var/clamav/.spamassassin root# ls -loa
    total 13128
    -rw------- 1 clamav clamav - 1310720 Feb 2 05:30 bayes_seen
    -rw------- 1 clamav clamav - 5410816 Feb 2 05:30 bayes_toks
    My final question goes to the X-Spam-*: headers.
    They should be in every mail that is delivered right? I only see these headers in mail with subject * JUNK MAIL *.
    Will this be fixed after the symlink is done so all mail has X-Spam-*: headers in them?

    Thanx Alex was waiting for your post.
    All appears well sudo su - clamav -c "sa-learn --dump magic"
    0.000 0 3 0 non-token data: bayes db version
    0.000 0 14789 0 non-token data: nspam
    0.000 0 1402 0 non-token data: nham
    0.000 0 182231 0 non-token data: ntokens
    0.000 0 1165964162 0 non-token data: oldest atime
    0.000 0 1170466264 0 non-token data: newest atime
    0.000 0 1170482415 0 non-token data: last journal sync atime
    0.000 0 1170465843 0 non-token data: last expiry atime
    0.000 0 2764800 0 non-token data: last expire atime delta
    0.000 0 12699 0 non-token data: last expire reduction count
    so that looks good. but I get this error now which i did not get before.
    ~ root# sudo su clamav -c "spamassassin --lint"
    su: Can't start from current directory: Permission denied
    su: Trying to start from "/var/clamav"
    $satag_leveldeflt was set to -999 so I don't know why all messages did not get X-Spam-*: headers?

  • How to write Question paper program in jsp....

    Hi..,
    This is sure from india. I would like to develop online examination project. Everything is ok. But i have a problem at deveop of question paper. I have 10 questions in my database. I would like display those questions one by one. How can i done this job. Please any one guide me. Because, i am new to this concept.
    with regards
    sure..)-

    First you need to extract all the question from database..
    Then put all of those questions in any of collection object...
    Then set this collection object in request as attribute..
    Keep this object in request till all question are not shown(you can eliminate questions after the have been asked)..
    Code might be like this.
    HashMap result = new HashMap();
    connection = .......;
    Statement stmt=connection.createStatement();
    rs = stmt.executeQuery("Your query");
    int count=0;
    while(rs.next())
    count++;
    String question = rs.getString("colName");
    result.put(""+count,question); //( ""+count)>>>>>means converting int to String
    request.setAttribute("questions",result);
    ====================================================
    now in every JSP which is intended to display a question will have to get this result object..
    Lets assume we are about to display first question()....
    ===========================================
    //////// First get result map from request
    HashMap questions = (HashMap)request.getAttribute("questions");
    String count;
    count = request.getAttribute("count");
    if(count==null)
    count="1";
    String question = questions.get(count);
    count = new String(""+(Integer.parseInt(count).intValue()+1));
    ///Now do what you have to do with this questionresult
    questions.remove();
    request.setAttribute("count",count);////setting question no in request
    request.setAttribute("questions",questions);////setting rest of questions in request
    ===================================================
    hope this might be helpful........
    if there is any problem you can consult me anytime

  • Reading and counting chars

    i need help on makeing a prog that takes a string a counts how many vowels are in the prog and prints how many there is any help will be greatly apreciated

    public class CountVowels {
       public static void main(String args[]) {
          String someString = "Hello there.  I am counting vowels";
          int vowelCounter = 0;
          for (int i=someString.length()-1;i>=0;i--) {
             char currentChar = someString.charAt(i);
             if (isVowel(currentChar)) {
                vowelCounter++;
          }//end for
          System.out.println("total vowels="+vowelCounter);
       }//end main
       public static boolean isVowel(char value) {
          boolean result = false;
          switch (value) {
             case 'a':
             case 'A':
             case 'e':
             case 'E':
             case 'i':
             case 'I':
             case 'o':
             case 'O':
             case 'u':
             case 'U':
                result = true;
          }//end switch
          return result;
       }//end isVowel
    }//end class

Maybe you are looking for

  • Help with multiple Mail accounts

    There are two user accounts on my computer. I am the administrator and recently set-up a .Mac email-only account for the secondary user. Now, in the Mail application, I am receiving the mail for both myself AND the secondary user in my box. How do I

  • IPhone 3GS can not detect SIM Card after upgraded to iOS 6.0.1

    Guys I really need your advice please... I upgraded my iPhone 3GS 32GB from iOS 5.1.1 to 6.0.1 a couple weeks ago and since then it can not detect the my SIM Card ever. Before it's been upgraded, the phone was working just fine, but now it's just lik

  • Problem with Adobe Pro and Reader on terminal server

    Hi, We have have a Terminal Server environment with Adobe Pro and Reader. We have security for Adobe Pro, so only certain user has access to Adobe Pro and all users has access to Adobe Reader. Some users receive many email with pdf's attachments in O

  • Combining PDFs

    How do I combine several PDFs into one PDF document?

  • Adobe PDF HELP

    hey guys i have updated my old adobe pdf from version 1.5 to 2.5 but now i have got 2 adobe pdf programs and i cant uninstall the old version for some reason,could anyone please help me. Solved! Go to Solution.