The program works. I get the correct output in Intellij IDEA. Every condition fails. Why is it not validating?
package com.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Vowels and consonants
*/
public class Solution {
public static char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
public static char[] consAndPer = new char[]{'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', '.'};
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String inputLineOne = null;
String inputLineTwo = null;
ArrayList<Character> vowelArr = new ArrayList<>();
ArrayList<Character> consArr = new ArrayList<>();
try {
inputLineOne = reader.readLine();
inputLineTwo = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
for(int i = 0; i<inputLineOne.length(); i++ ) {
if (isVowel(inputLineOne.charAt(i))){
vowelArr.add(inputLineOne.charAt(i));
}
else if (isCons(inputLineOne.charAt(i))){
consArr.add(inputLineOne.charAt(i));
}
}
for(int i = 0; i<inputLineTwo.length(); i++) {
if (isVowel(inputLineTwo.charAt(i))){
vowelArr.add(inputLineTwo.charAt(i));
}
else if (isCons(inputLineTwo.charAt(i))){
consArr.add(inputLineTwo.charAt(i));
}
}
for(int i = 0; i<vowelArr.size(); i++){
System.out.print(vowelArr.get(i)+" ");
}
System.out.println();
for(int i = 0; i < consArr.size(); i++){
System.out.print(consArr.get(i)+" ");
}
}
// The method checks whether a letter is a vowel
public static boolean isVowel(char c) {
c = Character.toLowerCase(c); // Convert to lowercase
for (char d : vowels) // Look for vowels in the array
{
if (c == d)
return true;
}
return false;
}
public static boolean isCons(char c) {
c = Character.toLowerCase(c);
for (char d :consAndPer)
{
if (c == d)
return true;
}
return false;
}
}