Write a class with a constructor that accepts a string


Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the number of vowels in the string, and another method that returns the number of consonants in the string. Demonstrate the class in a program that performs the following steps:

1. The user is asked to enter a string.

2. The program displays the following menu:

a. Count the number of vowels in the string

b. Count the number of consonants in the string

c. Count both the vowels and consonants in the string

d. Enter another string

e. Exit the program

3. The program performs the operation selected by the user and repeats until the user selects e, to exit the program.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write a class with a constructor that accepts a string
Reference No:- TGS01678035

Now Priced at $15 (50% Discount)

Recommended (93%)

Rated (4.5/5)