Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Eclipse Java Neon Write a program that reads in lines from the input. After each

ID: 3834270 • Letter: E

Question

Eclipse Java Neon

Write a program that reads in lines from the input. After each line is read in, it prints out the number of capital vowels, the number of capital consonants, and the number of other characters in the line.

Input

The input is just any line of characters

Output

The output will be the number of CAPITAL vowels (aeiou), the number of CAPITAL consonants (i.e. not vowels), and the number of other characters in the line. These are separated by a single space between them.

Sample Input

aokEKOkM49!4kP

AAAAOOPPPELL994920;[;];,<.>[

dv

Sample Output

2 3 9

7 5 16

0 0 2

HINT

Loop over the String a character at a time (using charAt(i) to get the character at index i).

Check if the character is a CAPITAL vowel (i.e. 'A' or 'E' or 'I' or 'O' or 'U'). ELSE check if is between 'A' and 'Z' -­using >= and <= // that means it must be a capital consonant ELSE it is something else.

Thank You!

Explanation / Answer

CharacterCountTest.java

import java.util.Scanner;


public class CharacterCountTest {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       System.out.println("Enter the string: ");
      
       while(scan.hasNext()){
           String line = scan.next();
           System.out.println();
       int capitalVowelCount = 0, capitalConsonentCount = 0, othersCount =0;
       for(int i=0; i<line.length(); i++){
           char ch = line.charAt(i);
           if(ch == 'A' || ch == 'E' ||ch == 'U' ||ch == 'I' ||ch == 'O') {
               capitalVowelCount++;
           }
           else if(Character.isUpperCase(ch)){
               capitalConsonentCount++;
           }
           else{
               othersCount++;
           }
       }
       System.out.println(capitalVowelCount+" "+capitalConsonentCount+" "+othersCount);
       }
   }

}

Output:

Enter the string:
aokEKOkM49!4kP
AAAAOOPPPELL994920;[;];,<.>[
dv
2 3 9

7 5 16

0 0 2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote