Question

Design and implement an application that reads a string from the user and then determines and...

Design and implement an application that reads a string from the user and then determines and prints how many of each vowel appear in the string. Have a separate counter for each vowel. Also, count and print the number of non-vowel characters.

Note: The characters in the string must be considered as case-insensitive. i.e., You must consider both upper and lowercase letters as same.

Example Output:

Enter a string:
hello

Number of each vowel in the string:
a: 0
e: 1
i: 0
o: 1
u: 0
other characters: 3

Homework Answers

Answer #1
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

Let me know for any help with any other questions.

Thank You!

===========================================================================

import java.util.Scanner;

public class VowelsFrequency {


    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter a string:");
        String text = scanner.nextLine();

        int aCount = 0, eCount = 0, iCount = 0, oCount = 0, uCount = 0;
        int otherCount = 0;

        for (int i = 0; i < text.length(); i++) {

            char letter = text.charAt(i);
            switch (letter) {
                case 'a':
                case 'A':
                    aCount += 1;
                    break;
                case 'e':
                case 'E':
                    eCount += 1;
                    break;
                case 'i':
                case 'I':
                    iCount += 1;
                    break;
                case 'o':
                case 'O':
                    oCount += 1;
                    break;
                case 'u':
                case 'U':
                    uCount += 1;
                    break;
                default:
                    otherCount++;
            }


        }


        System.out.println("a: " + aCount);
        System.out.println("e: " + eCount);
        System.out.println("i: " + iCount);
        System.out.println("o: " + oCount);
        System.out.println("u: " + uCount);
        System.out.println("other characters: " + otherCount);
    }
}

================================================================

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1 Design and implement FileCompare program that compares two text input files (file1.txt and file2.txt), line-by-line,...
1 Design and implement FileCompare program that compares two text input files (file1.txt and file2.txt), line-by-line, for equality. Print any lines that are not equivalent indicating the line numbers in both files. The language of implementation is java 2 . Create a program that reads a string input from the user, then determines and prints how many of each lowercase vowels (a, e. i, o, and u) appear in the entire string. Have a separate counter for each vowel. Also...
JavaScript When the button is pressed, the application should prompt the user to enter a string...
JavaScript When the button is pressed, the application should prompt the user to enter a string or ‘***’ to quit, and then print output in the text area specifying how many vowels were in the string. Vowels are the letters: a,e,i,o,u. The application should then again do the above, until the user enters ‘***’. It should then alert ‘Thanks for using the vowel counter’ and exit.
Write a JAVA program that reads in a string from standard input and determines the following:...
Write a JAVA program that reads in a string from standard input and determines the following: - How many vowels are in the string (FOR THE PURPOSE OF THIS PROGRAM 'Y' is NOT considered a vowel)? - How many upper case characters are in the string? - How many digits are in the string? - How many white space characters are in the string? - Modify the program to indicate which vowel occurs the most. In the case of a...
Write a Java application a String input by the user and shows whether the string contains...
Write a Java application a String input by the user and shows whether the string contains all 26 letters of the (English version of the Latin) alphabet. For example, "Pack my box with five dozen liquor jugs" contains all 26 letters, but "The quick frown box jumps over the hazy log" does not contain a d. It does not matter whether one or more letters appear more than once. needs, at minimum, asl user to input for the String, then...
java 8.1: Frequency Design and implement an application that reads an arbitrary number of integers that...
java 8.1: Frequency Design and implement an application that reads an arbitrary number of integers that are in the range 0 to 50 inclusive and counts how many occurrences of each are entered. After all input has been processed, print all of the values (with the number of occurrences) that were entered one or more times. The output should be one frequency count per line with the following format: 3 occurrences of 2 7 occurrences of 5 SPECIFICATION OF NAMES:...
Write a program that reads a string and outputs the number of lowercase vowels in the...
Write a program that reads a string and outputs the number of lowercase vowels in the string. Your program must contain a function with a parameter of a char variable that returns an int. The function will return a 1 if the char being passed in is a lowercase vowel, and a 0 for any other character. The output for your main program should be: There are XXXX lowercase vowels in string yyyyyyyyyyyyyyyyyyyyyy Where XXXX is the count of lowercase...
Write a Java application with a JavaFX GUI that takes a String input by the user...
Write a Java application with a JavaFX GUI that takes a String input by the user and shows whether the string contains all 26 letters of the (English version of the Latin) alphabet. For example, "Pack my box with five dozen liquor jugs" contains all 26 letters, but "The quick frown box jumps over the hazy log" does not contain a d. It does not matter whether one or more letters appear more than once. The GUI needs, at minimum,...
Using SLLStack.java, implement an application, LineReverser.java, that reads a line from keyboard (user enters one line),...
Using SLLStack.java, implement an application, LineReverser.java, that reads a line from keyboard (user enters one line), insert each separate word into the stack, and read/print on the screen. So, if the user enters: This is a test the application output should be: test a is This. This is SLLSTACK.java below package linked_lists; public class SLLStack {    //instance variabels    private SLLNode top;    private int numOfItems;       //constructors    public SLLStack() {        top = null;   ...
Design and implement a function with no input parameter which reads a number from input (like...
Design and implement a function with no input parameter which reads a number from input (like 123). Only non-decimal numbers are valid (floating points are not valid). The number entered by the user should not be divisible by 10 and if the user enters a number that is divisible by 10 (like 560), it is considered invalid and the application should keep asking until the user enters a valid input. Once the user enters a valid input, the program calculates...
This is function.py def processString(string): # Implement this function This is # This should print 4.5...
This is function.py def processString(string): # Implement this function This is # This should print 4.5 3.0 processString("An example. Two") # This should print 4.4 5.3 4.5 processString("This is the first sentence. The second sentence starts after the period. Then a final sentence") Download function.py and complete the processString(string) function. This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT