Question: Write a Java program to gather information about strings. Write your own user-defined methods to calculate vowel, digit, and white space counts using some Character
Write a Java program to gather information about strings. Write your own user-defined methods to calculate vowel, digit, and white space counts using some Character class methods. The Character class methods DO NOT count characters for you, that is what you must do.
There will be a loop in your main() method to read strings from the user until end of file (EOF) has occurred.
With each String read from the user, perform the following:
Report how many characters are in the string (length() String class method). Report how many vowels are in the string (no Java method exists to help with this). Report how many digits are in the string (isDigit() Character class method). Report how many letters are in the string (isLetter() Character class method). Report how many white-space characters are in the string (isWhitespace() Character class method). Consider writing methods as follows:
public static int numDigit(String s) { int count=0; // code to count digits // and you will need more than just the one variable... return count; } Your output should resemble:

Enter a string for character classification (EOF to end The quick brown fox jumps over the lazy do input Line The quick brown fox jumps over the lazy dog input Line is 44 characters long and contains the following: 8 whitespace characters. 0 digits. 35 letters. 11 vowels. Enter a string for character classification (EOF to end) 1-0-0-1-0-0-1 SOS input Line 1-0-0-1-0-0-1 SOS I input Line is 18 characters long and contains the following: 1 whitespace characters. 7 digits. 3 letters. 1 vowels. Enter a string for character classification (EOF to end)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
