Advertisement
tampurus

20 find vowels and consonent in a string

Apr 25th, 2022 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. // Q20 find vowels and consonent in a string
  2. import java.util.*;
  3. public class Main
  4. {
  5.     public static void main(String[] args) {
  6.         Scanner sc= new Scanner(System.in);
  7.         System.out.println("Enter the string");
  8.         String s =sc.nextLine();
  9.         s = s.toLowerCase();
  10.         char c;
  11.         for(int i=0 ; i<s.length() ; i++){
  12.             if(s.charAt(i)=='a'||s.charAt(i)=='e' || s.charAt(i)=='i'||s.charAt(i)=='o'||s.charAt(i)=='u')
  13.                 System.out.print("v-"+s.charAt(i)+" ,");
  14.             else
  15.                 System.out.print("c-"+s.charAt(i)+" ,");
  16.         }
  17.     }
  18. }
  19.  
  20.  
  21. /*
  22. Enter the string
  23. java
  24. c-j ,v-a ,c-v ,v-a
  25. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement