Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a method isPalindrome that accepts an array of Strings as its argument and

ID: 3933579 • Letter: W

Question

Write a method isPalindrome that accepts an array of Strings as its argument and returns true if that array is a palindrome (if it reads the same forwards as backwards) and false if not. For example, the array{"alpha", "beta", "gamma", "delta", "gamma", "beta", "alpha"} is a palindrome, so passing that array to your method would return true. Arrays with zero or one element are considered to be palindromes.

Write a static method named vowelCount that accepts a String as a parameter and produces and returns an array of integers representing the counts of each vowel in the String. The array returned by your method should hold 5 elements: the first is the count of As, the second is the count of Es, the third Is, the fourth Os, and the fifth Us. Assume that the string contains no uppercase letters. For example, the callvowelCount("i think, therefore i am") should return the array {1, 3, 3, 1, 0}.

**Just write methods. No class**

Explanation / Answer

public static boolean isPalindrome (String s[]){

       if(s.length == 0 || s.length == 1){
           return true;
       }
       else{
           for(int i=0; i<s.length/2; i++){
               if(!s[i].equals(s[s.length-1-i])){
                   return false;
               }
           }
           return true;
       }
   }

public static int[] vowelCount (String s){

       int vowels[] = {0,0,0,0,0};
       for(int i=0; i<s.length(); i++){
           if(s.charAt(i) == 'a' || s.charAt(i) == 'A'){
               vowels[0]++;
           }
           else if(s.charAt(i) == 'e' || s.charAt(i) == 'E'){
               vowels[1]++;
           }
           else if(s.charAt(i) == 'i' || s.charAt(i) == 'I'){
               vowels[2]++;
           }
           else if(s.charAt(i) == 'o' || s.charAt(i) == 'O'){
               vowels[3]++;
           }
           else if(s.charAt(i) == 'u' || s.charAt(i) == 'U'){
               vowels[4]++;
           }
       }
       return vowels;
    }

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote