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:

  1. The user is asked to enter a string.

  2. The program displays the following menu:

    1. Count the number of vowels in the string

    2. Count the number of consonants in the string

    3. Count both the vowels and consonants in the string

    4. Enter another string

    5. Exit the program

  3. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!