Write a java program to check palindrome string at least two different vowels

Write a program to check if a given string is palindrome and contains at least two different vowels.

Note Case Insensitive while considering vowel, i.e a & A are the same vowels, But Case sensitive while considering palindrome i.e abc CbA are not palindromes.

Input and Output Format:

Input consists of a string with a maximum size of 100 characters.

Output consists of a single Integer.

Refer sample output for formatting specifications.

Sample Input 1:


Sample Output 1:


Sample Input 2:


Sample Output 2:


Java program to check palindrome string at least two different vowels

package testCases;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Scanner;
public class MainJava {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
public static int display(String s) {
StringBuffer sb = new StringBuffer(s);
int k = 0;
LinkedHashSet<Character> l1 = new LinkedHashSet<Character>();
String s2 = sb.reverse().toString();
if (s2.equals(s)) {
String s3 = s2.toLowerCase();
for (int i = 0; i < s3.length(); i++) {
Iterator<Character> it = l1.iterator();
while (it.hasNext()) {
char a = it.next();
if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
if (k >= 2)
return 1;
return -1;


Leave a Reply

Your email address will not be published.

7 + two =