Count Vowels

Count Vowels

Read a string from the user, your program counts the number of vowels in the text and have it report a sum of each vowel found as well as the number of spaces. Make it in two classes

View Answers

May 17, 2011 at 11:47 AM

import java.util.*;

class CountVowels {
    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        System.out.print("Please enter string ");
        System.out.println();
        String str = input.nextLine();
        String st = str;

        char[] third = st.toCharArray();
        for (int counter = 0; counter < third.length; counter++) {
            char ch = third[counter];
            int count = 0;
            for (int i = 0; i < third.length; i++) {
                if (ch == third[i])
                    count++;
            }
            boolean flag = false;
            for (int j = counter - 1; j >= 0; j--) {
                if (ch == third[j])
                    flag = true;
            }
            if (!flag) {
                if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o'
                        || ch == 'u' || ch == ' ') {
                    System.out.println("Character " + ch + " occurs " + count
                            + " times ");
                }
            }
        }
    }
}









Related Tutorials/Questions & Answers:
Count Vowels
Count Vowels   Read a string from the user, your program counts the number of vowels in the text and have it report a sum of each vowel found as well as the number of spaces. Make it in two classes
Java count vowels
Java count vowels In this section you will learn how to count the number of vowels in String. Here you will ask to enter a string of your own choice and then you will get the number of vowels count. Description of code : In this code
Advertisements
Java Count Vowels
Java Count Vowels       In this program you will learn how to count vowels in a String. Here you... the number of vowels from that String. Description of the code:ADS_TO_REPLACE_1
vowels
vowels  program to count the number of vowels in a given array...++; } } System.out.println("There are" + " " + count + " " + "vowels... count = 0; for (int i = 0; i < ch.length; i++) { if (ch[i
vowels
vowels  how do u encryp vowels from given wordes?   import java.util.*; class EncryptVowels { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Enter
vowels and consonants
vowels and consonants   import java.lang.String; import java.io.*; import java.util.*; public class Vowels{ public static void main(String args[])throws IOException{ File aa = new File("C
NUMBER OF VOWELS IN A WORD
NUMBER OF VOWELS IN A WORD  WRITE A PROGRAM THAT WILL INPUT A WORD THEN IT WILL DETERMINE THE NUMBER OF VOWELS PRESENT IN THE INPUTTED WORD
ROTATE THE VOWELS IN A STRING!!! - Java Beginners
ROTATE THE VOWELS IN A STRING!!!  Hi Sir, My Question is to rotate the vowels, but not directly. First please read the question below... it changes the "vowel a to e", but doesn't change the rest of vowels, and i really
print word with max vowels
print word with max vowels  if suppose i hava entered a sentence and in that sentence i have to print a word which has maximum vowels in it.... i have tried it but i am not getting it...please help
Count number of "*"
Count number of "*"  I have this code to count the number of * from...:"); String text = bf.readLine(); int count = 0; for (int i = 0; i...); if (c=='*' ) { count
count in hibernate .
count in hibernate .  How to implements count in hibernate
count the users?
count the users?  how to get the number of users logged in any application
count characters
count characters  i have to print the total number of char 'A' in all... sabah sarawak terengganu the output must be count the total number of char... main(String[] args) { int count=0; Scanner input=new Scanner
to read a file and seperate vowels and consonants to other files
to read a file and seperate vowels and consonants to other files  import java.io.*; public class alpha { public static void main(String[] args)throws IOException { try { FileInputStream fstream = new FileInputStream
count objects php
count objects php  How to Count and show objects in PHP
Count Rows - JSP-Servlet
Count Rows  How to count rows in Java. Thanks
ModuleNotFoundError: No module named 'the_count'
ModuleNotFoundError: No module named 'the_count'  Hi, My Python... 'the_count' How to remove the ModuleNotFoundError: No module named 'the_count' error? Thanks   Hi, In your python environment you
SQLl query count and group by
SQLl query count and group by  How to write a sql query to count and group by the data?   Sql query to count the data and group the data using group by function... Select Name, Count(Name) As Count From Table Group
Hibernate Criteria Count Example
Hibernate Criteria Count Example  Example of Hibernate Criteria Count. Check the tutorial Hibernate Criteria Count. Check the Latest tutorials, articles and examples of Hibernate Framework. Thanks
php array loop count
php array loop count  Count the array using loop in php
MySQL Count
MySQL Count       This example illustrates how to use count() in MySQL database. Count(): The Count.... It returns a numeric value. If you use COUNT(*) that counts the number of rows.ADS
retain count in Objective C
retain count in Objective C  what is the retain count in Objective C?   retainCount in Objective c retainCount: retain count method is used to show the internal count of the given object so that programmer can easily
Count the character in java
Count the character in java  Write a java program to count....   Count characters by implementing thread import java.util.*; class CountCharacters { public static void count(final String str){ Runnable
Character count by while loop
Character count by while loop  Write the program to count the number...]; int count=0; for ( int i=0; i<third.length; i++){ if (ch==third[i]) count++; } boolean flag=false; for(int j=counter-1;j>=0;j--){ if(ch==third[j
Count distinct value in HQL.
Count distinct value in HQL.  How do you count distinct value in HQL?   count(distinct fieldName) returns number of distinct value... = sessionFactory.openSession(); String countHql = "Select count(distinct salary
Hibernate criteria count.
Hibernate criteria count.  How do we count rows using criteria in hibernate?   We can get the rows count using the Projections. My code is like this: Criteria criteria = session.createCriteria(getReferenceClass
Hibernate Count
In this section you will learn different way to count number of records in a table
count in java - Java Beginners
count in java  Hello javamania.... i want to ask something like... is 20. i have JFrame Form(jTextField,jLabel,jButton), i want to get count of gender, like if jTextfield =male then count of male=50 and if jTextfield=female
Count number of characters in a column.
Count number of characters in a column.  I just need you suggestions. Am from Biology Back ground. I just need to find out number of characters... to count characters in 1st, 2nd, 3rd columns seperatly and also print flase if i
Count Row - JSP-Servlet
Count Row  Hello all, Please I need your help on how to desplay... db = "register"; String driver = "com.mysql.jdbc.Driver"; int count= 0...(); ResultSet res = st.executeQuery("SELECT COUNT(*) FROM regiform
Count words in a string method?
Count words in a string method?  How do you Count words in a string...=br.readLine(); int count=0; String arr[]=st.split... count the length of arr which return the number of words in the inputted string
count asterisk in a grid - Java Beginners
count asterisk in a grid  I need to write a program that uses a recursive method to count the number of asterisk in a square grid
Using Min, Max and Count on HQL.
Using Min, Max and Count on HQL.  How to use Min, Max and Count on HQL
J2ME count character into string
J2ME count character into string  i am new in J2ME, my problem is how to count character into number, i had been research google for almost 2 days and got nothing...some one plz give me a punch :) as an example, 1. i got a text
Count instances of each word
Count instances of each word  I am working on a Java Project that reads a text file from the command line and outputs an alphabetical listing of the words preceded by the occurrence count. My program compiles and runs
Hibernate Criteria Count Distinct Example
Hibernate Criteria Count Distinct Example  I am learning Hibernate... Criteria Count Distinct. Can anyone tell me the best place to learn Hibernate Criteria Count Distinct? Thanks   Here is an example of Hibernate Criteria
ModuleNotFoundError: No module named 'atgcN-count'
ModuleNotFoundError: No module named 'atgcN-count'  Hi, My Python... 'atgcN-count' How to remove the ModuleNotFoundError: No module named 'atgcN-count' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'count-dict'
ModuleNotFoundError: No module named 'count-dict'  Hi, My Python... 'count-dict' How to remove the ModuleNotFoundError: No module named 'count-dict' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'count-dict'
ModuleNotFoundError: No module named 'count-dict'  Hi, My Python... 'count-dict' How to remove the ModuleNotFoundError: No module named 'count-dict' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'count-dict'
ModuleNotFoundError: No module named 'count-dict'  Hi, My Python... 'count-dict' How to remove the ModuleNotFoundError: No module named 'count-dict' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'count-dict'
ModuleNotFoundError: No module named 'count-dict'  Hi, My Python... 'count-dict' How to remove the ModuleNotFoundError: No module named 'count-dict' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'count-dict'
ModuleNotFoundError: No module named 'count-dict'  Hi, My Python... 'count-dict' How to remove the ModuleNotFoundError: No module named 'count-dict' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'count-files'
ModuleNotFoundError: No module named 'count-files'  Hi, My Python... 'count-files' How to remove the ModuleNotFoundError: No module named 'count-files' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'cpu-count'
ModuleNotFoundError: No module named 'cpu-count'  Hi, My Python... 'cpu-count' How to remove the ModuleNotFoundError: No module named 'cpu-count' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'pytest-count'
ModuleNotFoundError: No module named 'pytest-count'  Hi, My Python... 'pytest-count' How to remove the ModuleNotFoundError: No module named 'pytest-count' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'textLine_count'
ModuleNotFoundError: No module named 'textLine_count'  Hi, My... named 'textLine_count' How to remove the ModuleNotFoundError: No module named 'textLine_count' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'word-count'
ModuleNotFoundError: No module named 'word-count'  Hi, My Python... 'word-count' How to remove the ModuleNotFoundError: No module named 'word-count' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'word-count'
ModuleNotFoundError: No module named 'word-count'  Hi, My Python... 'word-count' How to remove the ModuleNotFoundError: No module named 'word-count' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'atgcN-count'
ModuleNotFoundError: No module named 'atgcN-count'  Hi, My Python... 'atgcN-count' How to remove the ModuleNotFoundError: No module named 'atgcN-count' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'char-count'
ModuleNotFoundError: No module named 'char-count'  Hi, My Python... 'char-count' How to remove the ModuleNotFoundError: No module named 'char-count' error? Thanks   Hi, In your python environment you

Ads