Home Answers Viewqa Java-Interview-Questions Find the percentage of words which starts with a vowel in a file

 
 


nisanth
Find the percentage of words which starts with a vowel in a file
1 Answer(s)      2 years and a month ago
Posted in : Java Interview Questions

  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 Pages:
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
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
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
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
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
how to show value and percentage in piechart sections from database using jfreechart
how to show value and percentage in piechart sections from database using... jfreechart.Now I need to display the values and their percentage in the sections... request The HttpServletRequest request, * which
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
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
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... + " words."); } } Output: File has 24 words
Programming: Count Words - Dialog
Java NotesProgramming: Count Words - Dialog Description Write a program which counts the number of words in text the user enters. Assume that a word... error-prone1 Hints Blank counter. The number of words it the number
Example - Read Words
Java Notes: Example - Read Words The program below reads a text file.../ReadWordsGUI.java // Purpose: Read a file and display all words in it. // Author... // Purpose: Read a file and display all words in it. // Author : Fred Swartz
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
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
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
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
Exercise - Capitalize Words
Java: Exercise - Capitalize Words Problem Write a method which which...-alphabetic. This is slightly more difficult than Exercise - Count Words... to be the same. capitalizeWords("Don't worry?")"Don'T Worry?The quote starts new word
Searching English words in a string
Searching English words in a string  My task is to find English words and separate them from a string with concatenated words..for example AhdgdjHOWAREgshshYOUshdhfh I need to find if there exists any English words.   
Exercise - Count Words
Java: Exercise - Count Words Problem Write a method which counts the number of words in a string. Assume that a word is defined as a sequence of letters.... countWords("Hello world")2Two words. countWords("Hello, world.")2Still two words
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
JavaScript split string into words.
JavaScript split string into words.  How to split string into words..., limit) is used in it, which is optional. separator specifies the character which is used for splitting the string. If you don?t put any separator
Count words in a string method?
count the length of arr which return the number of words in the inputted string...Count words in a string method?  How do you Count words in a string...(" "); System.out.println("Number of words : "+arr.length); }catch(IOException e
Java: Example - Words to array
Java: Example - Words to array This example shows how to convert words to an array. We will use StringTokenizer to achieve the this.   Some times is is required to words into an array, to solve this you can use
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
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
Please find me a solution that
Please find me a solution that   Write a java program..." has the following: a. Void Square Method with one parameter which is length of side. b. Void Rectangle Method has two parameters which are width and height
percentage values for <TD WIDTH=...>
percentage values for   Can I use percentage values for <TD WIDTH=...>
Programming: Count Words - Dialog
Java NotesProgramming: Count Words - Dialog Description Write a program which counts the number of words in text the user enters. Assume that a word... words, and so is "test this". Only count blanks if the last
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 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
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 
Breaking the String into Words
Breaking the String into Words     ... into words. The java.util.*; package provides you a simple method to breaking the string into separate words. This program takes a string from user and breaks
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
Can find a solution or code for this - XML
Can find a solution or code for this   Develop a java based tool which can be used to build a GUI structure based on the configurations given... the configuration file,mentioning the folders/files to be used.The tool then should read
Exercise - Count Words
Java: Exercise - Count Words Problem Write a method which counts the number of words in a string. Assume that a word is defined as a sequence of letters.... countWords("Hello world")2Two word. countWords("Hello, world.")2Still two words
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
Convert Number To Words
Convert Number To Words       In this example, We are going to convert number to words. Code... are going to make a method in which a parameter of integer type is passed. After
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
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  
How to find web hosting,find web hosting,right web host
hosting directory you will find may host, but now the real work starts. You next... is e-Comm web site then you try to find the plan which provides high Bandwidth... high fees. In this article I will provide some tips to find the right web host
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
file read
file read  hi i am reaing from a file which has punjabi words. can some one help with me some code
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
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
find SQL query created by Criteria - Hibernate
lignesDel = criteria.list(); where would I find my SQL code which is generated? Will it be in some DAO file or it is generated on the fly ? Thanks, Sandeep...find SQL query created by Criteria  Hi there, I am new
Java Reverse words of the String
Reverse words of the String Java Programming In this section, we are going to reverse the words of the string. For this, we have allowed the user to enter... which return the reverse order of the tokens. Here is the code
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
Doclets Find Bad Code - Java Tutorials & Doclets Tutorial
Doclets Find Bad Code 2001-11-17 The Java Specialists' Newsletter [Issue 035] - Doclets Find Bad Code Author: Dr. Heinz M. Kabutz If you are reading... and tell us what you think. On that forum I've posted a way in which you can
.jar file keeps giving me " could not find the main class". Program will exit.
.jar file keeps giving me " could not find the main class". Program will exit... clean and build it which produces a .jar file in my dist folder. When I double... even with a simple file that displays a jframe with a jlabel on it. My
Example: Count Bad Words
Java NotesExample: Count Bad Words Your grandmother has learned to program... the grandchildren's email to make sure they aren't using any "bad" words. She doesn't know how to read a file yet, so she's going to test her ideas with this little

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.