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

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

This is what I have so far:

import java.util.Scanner; public class vowelsConsonants { private static String sentence; public vowelsConsonants(String str) { sentence=str; } public static int vowelCount() { int count=0; for (int i=0;i

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!