Create a program with a method that takes a single character and returns true if the character is a vowel otherwise return false.
import java.util.Scanner;
public class Main
{
static boolean isVowel(char c){
if(c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
return true;
}
else{
return false;
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
char c;
System.out.print("Enter a character: ");
c=sc.next().charAt(0);
System.out.println(isVowel(c));
}
}
Comments
Leave a comment