OOP-JAVA Practical 6

OOP-JAVA Practical 6
  • Aim: Write a program that prompts the user to enter a letter and check whether a letter is a vowel or Constant.
  • Code:
    import java.util.*;
    public class practical6{
        public static void main(String args[]){
            char c;
            Scanner s = new Scanner(System.in);
            System.out.println("Enter a Letter:");
            c=s.next().charAt(0);
            if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U'){
                System.out.println("Letter is Vowel");
            }
            else{
                System.out.println("Letter is Constant");
            }
        }
    }
  • Output:
    Output of practical 6

Comments