Question
--JAVA PROGRAMMING LANGUAGE-- Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns
--JAVA PROGRAMMING LANGUAGE--
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:
-
The user is asked to enter a string.
-
The program displays the following menu:
-
Count the number of vowels in the string
-
Count the number of consonants in the string
-
Count both the vowels and consonants in the string
-
Enter another string
-
Exit the program
-
-
The program performs the operation selected by the user and repeats until the user selects e, to exit the program.
CHANGES:
-- Instead of Vowels, you will be finding numbers and instead of consonants, you will be finding spaces. We will also be finding substrings. We will call our version "Numbers, Spaces & Substrings".
#2a should now say "Count the number of numbers in the string'
#2b should now say "Count the number of spaces in the string"
#2c should now say "Count the number of times a substring appears in the string" (ask user to give substring)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started