Problem Statement
Write a program to print the smallest vowel in a given string
Input
matrix
Output
a
Explanation
The vowels in the given string are a and i. And the alphabetically smallest between them is a.
code:
import java.util.Scanner;
class Solution{
public static void main(String args[]){
Scanner str=new Scanner(System.in);
String word=str.nextLine();
str.close();
String []vowels={"a","e","i","o","u"};
for(int i=0;i<vowels.length;i++){
if(word.contains(vowels[i])){
System.out.println(vowels[i]);
break;
}
}
}
}
Comments
Post a Comment