Answer to Question #257549 in Java | JSP | JSF for NUCHO

Question #257549

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-10-27T16:25:27-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 in=new Scanner(System.in);
	    char ch;
	    System.out.print("Enter a character: ");
	    ch=in.next().charAt(0);
	    System.out.println(isVowel(ch));
	}
}

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