Find the percentage of words which starts with a vowel in a file

Find the percentage of words which starts with a vowel in a file

  1. Question: Find the percentage of words which starts with a vowel in a file. Ex: Input: Contents of File1- There is an endless loop in the program.

Output: Vowel Percentage: 50%.

View Answers

April 28, 2011 at 2:56 PM

import java.io.*;
import java.util.*;
import java.text.*;
import java.util.regex.*;

public class FindPercentage{
    public static void main(String[] args){
        try{
        double count=0,vowel=0;
        BufferedReader br=new BufferedReader(new FileReader(new File("C:/hello.txt")));
        String ss="";
        StringBuffer buffer=new StringBuffer();
        while((ss=br.readLine())!=null){
            buffer.append(ss);
        }
        String st = buffer.toString();
        String str = st.replaceAll("[?!.]", "");
        StringTokenizer tokenizer = new StringTokenizer(str);
        String s = "";
        while(tokenizer.hasMoreTokens()) {
            s = tokenizer.nextToken().toLowerCase();
            if((s.startsWith("a")) || (s.startsWith("e"))||(s.startsWith("i")) || (s.startsWith("o"))|| (s.startsWith("u"))) {
                vowel++;
            }
            count++;
        }
        System.out.println("Total Number of words: "+count);
        System.out.println("No of words that starts with vowel: "+vowel);
        double value=vowel/count;
        double percentage=value*100;
        DecimalFormat df=new DecimalFormat("##.##");
        System.out.println("Vowel Percentage: "+df.format(percentage));
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
}









Related Tutorials/Questions & Answers:
Find the percentage of words which starts with a vowel in a file
Find the percentage of words which starts with a vowel in a file   Question: Find the percentage of words which starts with a vowel in a file. Ex: Input: Contents of File1- There is an endless loop in the program. Output: Vowel
tO FIND UNIQUE WORDS IN A FILE USING HASHMAP
tO FIND UNIQUE WORDS IN A FILE USING HASHMAP  import java.util....())); } System.out.println("Number of unique words in file "+cc...() { // create a HashMap to store unique combination of words
Advertisements
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
accept sentence from user and print all word starts with vowel and end with consonent
accept sentence from user and print all word starts with vowel and end with consonent  Write a program to accept a sentence. Print all the words that starts with vowel and end with a consonant. e.g. input by user "the purpose
vowel
vowel  display all the vowel from word/string   import java.util.*; class DisplayVowels { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter
display co-occurrence words in a file
display co-occurrence words in a file  how to write java program for counting co occurred words in the file
display co-occurrence words in a file
display co-occurrence words in a file  how to write java program for counting co occurred words in the file
Java count words from file
Java count words from file In this section, you will learn how to determine the number of words present in the file. Explanation: Java has provides several...++; } System.out.println("File has " + count + " words."); } } Output:ADS_TO_REPLACE_3
program to display all words in the file in the sorted order without duplicates
program to display all words in the file in the sorted order without duplicates  I want a java program which accepts a file from user and displays all words in the file in the sorted order without duplicates
display all words containing the letter which i gave as input...
display all words containing the letter which i gave as input...  If i enter any character,it have to display the names which having that character..write a program using java example(output) Enter any character: a Names: Abi
java program to insert data into a file and count the number of words from the file???????
java program to insert data into a file and count the number of words from the file???????  java program to insert data into a file and count the number of words from the file
Display non-duplicate words from file
object is then passed to StringTokenizer which broke the text of file into words...Display non-duplicate words from file In this tutorial, you will learn how to read a text file and display non-duplicate words in ascending order. The given
Map words to line number in text file and show occurence
Map words to line number in text file and show occurence  hi i want to Map words to line number in text file and show occurrence of word in java coding
Find Numbers which are palindrome and prime
Find Numbers which are palindrome and prime In this section, you will learn how to find the numbers from 1 to 500 which are palindrome and prime. To compute...() of boolean type. Now the list contains all the numbers which are palindrome
To find palindrome no in a file - Java Beginners
To find palindrome no in a file  hi all i am having a problem...I wanted to write one java program where i have to count the no of palindrome in a file. I tried it with my own but not able to get result.pls help me out  
Program to count the number of unique words in a file using HashMap
Program to count the number of unique words in a file using HashMap  ...[]) throws FileNotFoundException { File f = new File("C:/547647/word...()); System.out.println("The number of unique words: "+uniqueValues.size
java string vowel program
java string vowel program  java string vowel program   Please visit the following links: Display the word that begins with vowel Java Count Vowels
Find currenly which field is having focus on html page? - Ajax
Find currenly which field is having focus on html page?  Hi All... don't know which form user want's to be submit. So I am trying to get which field.... So how do I fiend currently which field having focus? Please reply
Java latest file
Java latest file In this section, you will learn how to find the file which is generated or modified at last. Description of code: To find the last modified file, we have used the Comparator interface that compare the files 
percentage values for <TD WIDTH=...>
percentage values for   Can I use percentage values for <TD WIDTH=...>
putting words to line number form a java file/test file and show occurrence
putting words to line number form a java file/test file and show occurrence  hi all i want putting words to line number form a java file and show occurrence but i cant use mapping method i can only use the LinkedList
find out in servlet which button was clicked on an html page
find out in servlet which button was clicked on an html page  i have two buttons on my jsp page... and i want two call two seperate codes in a servlet on pressing of those 2 buttons.. how do i find out which button was clicked so
which is good hadoop file system commands tutorial
which is good hadoop file system commands tutorial  Hi, I am learning hadoop file system commands and trying to find all commands of hadoop with examples. which is good hadoop file system tutorial? Thanks   Hi
which is good hadoop file system commands tutorial
which is good hadoop file system commands tutorial  Hi, I am learning hadoop file system commands and trying to find all commands of hadoop with examples. which is good hadoop file system tutorial? Thanks   Hi
Which extension i use for save hibernate file.
Which extension i use for save hibernate file.   Please give me answer that which extension i use for save the hibernate file and how i run that file as well as complie that file.   hi friend, Naming convention
java vowel program - Java Beginners
java vowel program  Write a program to Print all the words that start with a vowel and end with a consonant. For example : Input :‚??the purpose...')){ String words=w.substring(0,w.length()-1)+ch1; System.out.println(words
How to find a config file in spring project
How to find a config file in spring project  how to find configuration file in the spring project
storing records which of a file into a table of mssql database
storing records which of a file into a table of mssql database  I have a requirement like this, A file contains some records with headers same as column names of a table. I have to store those records into a table
find zip file length lessthen 5MB
find zip file length lessthen 5MB  import java.io.BufferedReader... File folder = new File(source); if(folder.exists... :"); detination=readkeyboard.readLine(); File[] files
Program to find no of metrics in a file ----- Java code
Program to find no of metrics in a file ----- Java code  Hi Friends, I got a task to calculate the metrics of a program, like to find... the no of SELECT and INSERT statements but unable to find tablewise. E.G Table
ModuleNotFoundError: No module named 'vowel-versificon'
ModuleNotFoundError: No module named 'vowel-versificon'  Hi, My... named 'vowel-versificon' How to remove the ModuleNotFoundError: No module named 'vowel-versificon' error? Thanks   Hi, In your
How to read the contents in a file which is of input type file
How to read the contents in a file which is of input type file  I have a jsp page wherein i have to passs the file as input and read the contentsn of a file in servlet. upload.jsp <FORM METHOD=POST ENCTYPE="multipart/form
Find the date of the file before the file has been modified
Find the date of the file before the file has been modified  Hi, may i know is it possible to find the date of the file before the file has been modified?   hi friend, you can get the date of last modified file using
Find number of words begin with the specified character
Count number of words begin with the specified character In this section, you will learn how to count the number of words that begin with the specified... with the input character. If found, counter will count the words. Here is the code
Error 500-Server are not find the jar file in the program of upload the file - JSP-Servlet
Error 500-Server are not find the jar file in the program of upload... a program to upload a file.I include the commons-fileupload-1.2.1.jar file in lib...); // Create a new file upload handler System.out.println(isMultipart); DiskFileUpload
in unix which command is used to sort the lines of data in a file in reverse order
in unix which command is used to sort the lines of data in a file in reverse order  in unix which command is used to sort the lines of data in a file... the lines of data in a file in reverse order
Create an HTML file AddCookies.html which contains four text boxes
Create an HTML file AddCookies.html which contains four text boxes  Create an HTML file AddCookies.html which contains four text boxes .When user enters the values in these text boxes and press the submit button, the values
I want to know the given class name exists in which jar file?
I want to know the given class name exists in which jar file?   I want to know the given class name exists in which jar file? C:\Program Files\IBM... the name of the jar file where 'com.rational.ft.util.debug' class exists
Need to find the position of delimiter in a file using java - Java Beginners
Need to find the position of delimiter in a file using java  Hi , will any one give me a solution to find the Need to find the position of delimiters in a file using java.Please do reply
find jar file name from multiple set of jar files
find jar file name from multiple set of jar files   I would like to find jar file name from multiple set of jar files where the given class name√Ę‚?¨¬?com.rational.ft.util.debug√Ę‚?¨¬
Formatting and Parsing a Locale-Specific Percentage
Formatting and Parsing a Locale-Specific Percentage In this section, you will learn how to format and parse a locale-specific percentage. On the basis of customizable patterns, which includes a combination of literal and special
Given a list, identify which are requirements for an EJB-jar file.
Given a list, identify which are requirements for an EJB-jar...;   Given a list, identify which are requirements for an EJB-jar file. The ejb-jar file MUST CONTAIN, either
Java - search/find a word in a text file - Java Beginners
Java - search/find a word in a text file  Hello, I would like to know how to find from a list of lets say 10 but could be more, .txt files, how... want to do nothing, if FAIL, I want to record in 1 master output file, the name
how to edit xml file which is currently running in web server - XML
how to edit xml file which is currently running in web server  Hello, I want to add new element in xml file which is currently running in my web server apache tomcat.I can add and modify xml file by giving Path like that "E
Want to access my Ms-access Db file which is placed inside the same Jar file
Want to access my Ms-access Db file which is placed inside the same Jar file  how do i access my Ms-Access file placed in the same jar file where my...-access via JDBC but cant find the file wen kept inside the same jar
ModuleNotFoundError: No module named 'black-percentage-tester'
ModuleNotFoundError: No module named 'black-percentage-tester'  Hi...: No module named 'black-percentage-tester' How to remove the ModuleNotFoundError: No module named 'black-percentage-tester' error? Thanks   
ModuleNotFoundError: No module named 'odoo12-addon-web-group-by-percentage'
ModuleNotFoundError: No module named 'odoo12-addon-web-group-by-percentage...: ModuleNotFoundError: No module named 'odoo12-addon-web-group-by-percentage' How...-by-percentage' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'trytond-carrier-percentage'
ModuleNotFoundError: No module named 'trytond-carrier-percentage'  Hi...: No module named 'trytond-carrier-percentage' How to remove the ModuleNotFoundError: No module named 'trytond-carrier-percentage' error? Thanks
ModuleNotFoundError: No module named 'black-percentage-tester'
ModuleNotFoundError: No module named 'black-percentage-tester'  Hi...: No module named 'black-percentage-tester' How to remove the ModuleNotFoundError: No module named 'black-percentage-tester' error? Thanks   

Ads