Write a program to accept a word and pass this word to a function name void display(String str). Display all the vowels present in the word in java.

 Write a program to accept a word and pass this word to a function name void display(String str). Display all the vowels present in the word in java.



public class ReturnVowel
{
  static void display(String str){
    String s = str.toLowerCase();
    for(int i=0;i<s.length();i++){
        if(s.charAt(i)=='a'||s.charAt(i)=='e'||s.charAt(i)=='i'||s.charAt(i)=='o'||s.charAt(i)=='u'){
        System.out.println(str.charAt(i));
        }
    }
    }
  public static void main(String args[]){
    String name = "cOmputer";
    display(name);
    }
}

Output
O u e

Comments

Popular posts from this blog

How to make simple bill maker by using python tkinter

Make a GST Calculator using HTML and JavaScript

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java