Assignment: Module 03- Part 03
![]() |
Write a class VowelCount to accept a character and display it vowel or not.
Input:
Enter a character b
Output:
It is not a vowel
Input:
Enter a character e
Output:
It is a vowel
Here is a sample code for the class VowelCount in Java:
import java.util.Scanner;
public class VowelCount {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a character: ");
char ch = sc.next().charAt(0);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') {
System.out.println("It is a vowel");
} else {
System.out.println("It is not a vowel");
}
}
}
Example output for b:
Enter a character: b
It is not a vowel
Example output for e:
Enter a character: e
It is a vowel