Computer Science, asked by raunak9879, 5 months ago

Write a program in Java to accept a character. Check and print whether it is vowel or not.​

Answers

Answered by samarthkrv
1

Answer:

import java.io.*;

public class Main

{

   static boolean isVowel(char y)

       {

           if(y=='a' || y=='e' || y=='i' || y=='o' || y=='u' || y == 'A' || y == 'E' || y == 'I' ||y ==  'O' ||y == 'U')

               {

                   return true;

               }

           else

               {

                   return false;

               }

       }

public static void main(String[] args) throws Exception {

 System.out.print("Enter a char:");

 char c = (char)System.in.read();

     if(isVowel(c))

         {

             System.out.println("It is vowel");

         }

     else

         {

             System.out.println("It is not a vowel");

         }

}

}

Explanation:

Similar questions