GTU OOP Program - 6
6). Write a program that prompts the user to enter a letter and check whether a letter is a vowel or constant.
- import java.util.Scanner;
- class Program_06 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter the Character : ");
- char ch = input.next().charAt(0);
- switch (Character.toLowerCase(ch)) {
- case 'a':
- case 'e':
- case 'i':
- case 'o':
- case 'u':
- System.out.print(ch + " is a vowel");
- break;
- default:
- System.out.print(ch + " is a consonant");
- break;
- }
- }
- }
Output
Comments