in java Assume letters A E I O and U as the vowels Write a p
in java
Assume letters A, E, I, O, and U as the vowels. Write a program that prompts the user to enter a string and displays the number of vowels and consonants in the string. Enter a string: Programming is fun The number of vowels is 5 The number of consonants is 11Solution
VowelandConsonent.java
 import java.util.Scanner;//package for keyboard inputting
public class VowelandConsonent {//main class
    public static void main(String args[]) {//main method
         System.out.println(\"Please enter any String\");
         Scanner reader = new Scanner(System.in);
        String input = reader.nextLine();//key board inputting
         char[] Str = input.toCharArray();
int cnt1 = 0, cnt2 = 0;
        for (char c : Str) {//for each loop
             switch (c) {
                 case \'a\':
                 case \'e\':
                 case \'i\':
                 case \'o\':
                 case \'u\':
                 case \'A\':
                 case \'E\':
                 case \'I\':
                 case \'O\':
                 case \'U\':
                     cnt1++;//it increments is string present vowels
                     break;
                 case \'b\':
                 case \'c\':
                 case \'d\':
                 case \'f\':
                 case \'g\':
                 case \'h\':
                 case \'j\':
                 case \'k\':
                 case \'l\':
                 case \'m\':
                 case \'n\':
                 case \'p\':
                 case \'q\':
                 case \'r\':
                 case \'s\':
                 case \'t\':
                 case \'v\':
                 case \'w\':
                 case \'x\':
                 case \'y\':
                 case \'z\':
                     case \'B\':
                 case \'C\':
                 case \'D\':
               
                  case \'F\':
                 case \'G\':
                 case \'H\':
               
                  case \'J\':
                 case \'K\':
                 case \'L\':
                 case \'M\':
                 case \'N\':
               
                  case \'P\':
                 case \'Q\':
                 case \'R\':
                 case \'S\':
                 case \'T\':
               
                  case \'V\':
                     case \'W\':
                         case \'X\':
                             case \'Y\':
                                 case \'Z\':
cnt2++;//it increments if it contains consonents
default:
                 // no count increment
             }
        }
         System.out.println(\"Number of vowels in String [\" + input + \"] is : \" + cnt1);
         System.out.println(\"Number of consonents in String [\" + input + \"] is : \" + cnt2);
     }
}
output
Please enter any String
 Programming is fun
 Number of vowels in String [Programming is fun] is : 5
 Number of consonents in String [Programming is fun] is : 11


