Computer Science, asked by queen3059, 6 months ago

19. Write a program in Java that reads a word and checks whether it begins with a vowel or not.​

Answers

Answered by rimisharauniyar22
1

Answer:

import java.util.Scanner;

public class VowelOrConsonant {

  public static void main(String args[]){

     System.out.println("Enter a character :");

     Scanner sc = new Scanner(System.in);

     char ch = sc.next().charAt(0);

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

        System.out.println("Given character is an vowel");

     }else{

        System.out.println("Given character is a consonant");

     }

  }

}

Explanation:

Similar questions