Answer to Question #259941 in Java | JSP | JSF for Wunna

Question #259941

 Create a program with a method that takes a single character and returns true if the character is a vowel otherwise return false.


1
Expert's answer
2021-11-01T18:57:25-0400
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));
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS