// WAP TO COUNT THE NUMBER OF VOWELS, CONSONANTS IN THE GIVEN STRING. import java.util.Scanner; class StringPractice{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a string:"); String s1 = sc.nextLine(); String s2 = s1.toLowerCase(); int cvowel = 0; int cconsonant = 0; int cdigit = 0; int cspecial = 0; for(int ch = 0;ch < s2.length();++ch) { char i = s2.charAt(ch); if(i == 'a' || i == 'e' || i == 'i' || i == 'o' || i == 'u') { cvowel++; } else if(i >= 'a' && i <= 'z') { cconsonant++; } else if(i >= '0' && i <= '9') { cdigit++; } else { cspecial++; } } System.out.println("Number of Vowels = "+cvowel); System.out.println("Number of Consonants = "+cconsonant); System.out.println("Number of Digits = "+cdigit); System.out.println("Number of Other Characters = "+cspecial); } } ===================================================== WAP TO CHECK WHETHER THE GIVEN STRING IS PALINDROME OR NOT. class StringPractice{ public static void main(String[] args) { String s1 = new String("level"); String s2 = new String(); char ch; // String s2 = ""; for(int i = s1.length()-1;i >= 0;--i) { ch = s1.charAt(i); // l e v e l s2 = s2 + ch; // "level" } System.out.println(s2); System.out.println(s1); boolean b = s1.equals(s2); System.out.println(b); if(b) { System.out.println("The strings are Palindrome Strings."); } else { System.out.println("The Strings are not Palindrome Strings."); } } } ====================================================== WAP TO CHECK WHETHERE THE TWO STRINGS ARE ANAGRAMS OR NOT. ========================================================== 1) DEFINE TWO STRINGS 2) CONVERT BOTH THE STRINGS INTO SAME CASE 3) CHECK WHETHER TWO STRINGS ARE WITH SAME LENGTH OR NOT. 4) IF LENGTHS ARE SAME: s1 ==> Character array s2 ==> character array sorting on s1 and s2 5) convert arrays to strings by using join(). 6) s1.equals(s2) = true/false