Computer Science, asked by mishravaibhav365, 2 months ago

Question 4:
Design a class countfreq following details
Class name: countfreq
Data Members:
str : to store any sentence
freq : stores the frequency of words present in the sentence which contain
more number of digits than alphabets
Member functions:
countfreq ( ) : default constructor
void accept(String x) : assign x to str
int countdigit(String w) : counts and returns the total number of digits present in string w
int countalpha(String w) : counts and returns the total number of alphabets present in string w
void display() : invokes the above two functions and prints those words
of the string str which has more number of digits than alphabets. also print the frequency of such words present in str.
Specify the class countfreq giving details of constructor and other methods.
Write the main() function to create the object of the class and call the methods
accordingly.

Answers

Answered by gamingturtlebeach935
0

Answer:

:

Design a class countfreq following details

Class name: countfreq

Data Members:

str : to store any sentence

freq : stores the frequency of words present in the sentence which contain

more number of digits than alphabets

Member functions:

countfreq ( ) : default constructor

void accept(String x) : assign x to str

int countdigit(String w) : counts and returns the total number of digits present in string w

int countalpha(String w) : counts and returns the total number of alphabets present in string w

void display() : invokes the above two functions and prints those words

of the string str which has more number of digits than alphabets. also print the frequency of such words present in str.

Specify the class countfreq giving details of constructor and other methods.

Write the main() function to create the object of the class and call the methods

accordingly

Similar questions