Write a class VowelCount to accept a character and display it vowel or not.

0

Assignment: Module 03- Part 03

Write a class VowelCount to accept a character and display it vowel or not.

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   

👉Write a class CountArray to accept the values and count the total number of negative and positive numbers and display it separately👈

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates