Q.Write a java program to display all the vowels from a given string. [15 M]
import java.util.Scanner;
public class DisplayVowels {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = sc.nextLine();
System.out.println("Vowels in the given string are:");
for(int i = 0; i < str.length(); i++) {
char ch = Character.toLowerCase(str.charAt(i));
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
System.out.print(str.charAt(i) + " ");
}
}
sc.close();
}
}