Sunday, 10 January 2021

Java Program to accept a letter and check Whether a character is Vowel or Consonant.

 import java.util.*;

public class Main

{

    public static void main(String args[])

    {

    Scanner in=new Scanner(System.in);    

    char ch;

    System.out.println("Enter a Character to check whether it is a vowel or a Constant");

    ch=in.next().charAt(0);

    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')

    System.out.println(ch+" is a Vowel.");

    else 

    System.out.println(ch+" is a Constant.");

    }

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...