Write a class with a constructor that accepts a String object as its argument. The class should
Question:
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.
Step by Step Answer:
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis