Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


nisanth
Find the percentage of words which starts with a vowel in a file
1 Answer(s)      3 years and 7 months 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%.


Advertisement
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
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
Advertisements
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
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
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
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... + " words."); } } Output: File has 24 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
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
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
percentage values for <TD WIDTH=...>
percentage values for   Can I use percentage values for <TD WIDTH=...>
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
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
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
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
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
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  
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
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
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
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
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
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 
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
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
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
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
 

 

 

DMCA.com