Programming Shortcut

Write, Run and execute Your programs with simple and esay way by Programming Shortcut

Friday, February 15, 2019

Program to check a letter is vowel or consonant in java


Hello Friends! Welcome to programming shortcut
Today will discuss:
--> Program to find whether the alphabet is a vowel or consonant  in java or
--> java program to check vowel or consonant using a switch or
--> program to check an alphabet is a vowel or consonant in java or
--> Program to find whether the letter is a vowel or consonant  in java or
--> program to check a letter is a vowel or consonant in java


import java.util.Scanner;
public class Check_letter_to_vowel_or_consonant {
    public static void main(String[] args) {
       String ch;
       Scanner c = new Scanner(System.in);
       System.out.println("Enter letter to check vowel or consonant:");
       ch = c.next();
       switch(ch){
           case "a":
           case "e":
           case "i":
           case "o":
           case "u":
           case "A":
           case "E":
           case "I":
           case "O":
           case "U":
           System.out.println("The alphabet is a vowel");
           break;
           default:
           System.out.println("The alphabet is a consonant");
       }
    }
}



Output:

   First, run:
   Enter letter to check vowel or consonant:
   a
   The alphabet is a vowel

   Second-time run:
   Enter the alphabet :
   d
   The alphabet is a consonant

Explanation: In this programming, we use the Switch case to check an alphabet or a letter is a vowel or consonant


Hello, Friend We first write the program and compile them and run the program to check compiler error or run time error.
Please share the site and comment on your ideas and your suggestions. All suggestion was all welcome.
If any question or doubt in the programming please mention the comment.
Thank yours very much. 

Programming Shortcut is collections in java best programs with example, best c programs with example and best c++ programs with example, best way to learn java, c and c++

About Programming Shortcut

This is a programming learning website that can help you learn and when your write your programming code. And all programming code is compiled run programming code in the following programming language C, c++, Java, php and Javascript Languages. find your programming read, understand the programming then copy and past and run your program and save your golden time to typing the program becuse you learn more in leas time. All Programming is codeing is ease to understand the programming