Codex

Check whether a character is vowel or not

Jul 22nd, 2011
1,475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. import java.util.Scanner;
  2. {
  3. public static void main(String args[])
  4. {
  5. Scanner sc=new Scanner(System.in);
  6. System.out.println("Enter a character");
  7. char ch=(sc.next).charAt(0);
  8. if(isVowel(ch))
  9. System.out.println("A vowel");
  10. else
  11. System.out.println("Not a vowel");
  12. }
  13. public static boolean isVowel(char c)
  14. {
  15. if(c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' || c=='u' || c=='U')
  16. return true;
  17. else
  18. return false;
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment