Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
13.9k views
in Computer by (49.9k points)
closed by

Design a class VowelWord to accept a sentence and calculate the frequency of words that begin with a vowel.The words in the input string are separated by a single blank space and terminated by a full stop. The description of the class is given below:

Class name: VowelWord Data Members/instance variables: 

str: to store a sentence freq: store the frequency of the words beginning with a vowel. Member functions: 

VowelWord(): constructor to initialize data members to a legal initial value void readstr(): to accept a sentence

void freq_vowel: counts the frequency of the words that begin with a vowel 

void display(): to display the original string and the frequency of the words that begin with a vowel. 

Specify the class VowelWord giving details of the constructor (), void readstr (), void freq_vowel () and void display (). Also, and call the methods accordingly to enable the task.define the main () function to create an object

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

import java.io.*; 

class VowelWord 

String str; 

int freq; 

public VowelWord() 

str = "Evergreen Publications, Jalandhar, Punjab"; 

freq = 0; } void readstr( )throws IOException 

BufferedReader br = new 

BufferedReader (new InputStreamReader (System.in)); 

System.out.println('Enter a Sentence.'); str = br.readLine (); 

void freq vowel() 

String w; 

int i , l; 

char ch; 

l = str.length(); 

for (i = 0; i< 1; i++) 

{

w = " "; 

while(str.charAt (i) ! = '' && 

str.chartAt(i)! =' ') 

{ w = w + str.charAt (i); i++; 

w = w.toLowerCase(); 

ch = w.charAt(0); 

if (ch == 'a' || ch == 'e' || ch = 'i' || ch = 'o' || ch = 'u') { freq++; 

}

void display() 

System.out.println("Original String : " + str); 

System.out.println("Frequency of Words Beginning with vowel are : " + freq); 

public static void main(String args[])throws IOException 

VowelWord ob = new VowelWord(); 

ob.readstr(); 

ob.ffeq _vowel(); 

ob.display( ); 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...