Ad
Code
Diff
  • public class Encrypt {
      
      public static String encryptByVowels(String str) {
        int vowel = 0;
    		for (int i = 0; i < str.length(); i++) {
    			if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o'
    					|| str.charAt(i) == 'u' || str.charAt(i) == 'A' || str.charAt(i) == 'E' || str.charAt(i) == 'I'
    					|| str.charAt(i) == 'O' || str.charAt(i) == 'U') {
    				vowel++;
    			}
    		}
    
    		StringBuilder strBuilder = new StringBuilder();
    		char c = 0;
    		for (int i = 0; i < str.length(); i++) {
    			if (str.charAt(i) == 32) {
    				strBuilder.append(" ");
    			} else {
    				if ((str.charAt(i) + vowel) > 90 && (str.charAt(i) + vowel) < 97) {
    					c = (char) (96 + ((str.charAt(i) + vowel) % 90));
    				} else if ((str.charAt(i) + vowel) > 122) {
    					c = (char) (64 + ((str.charAt(i) + vowel) % 122));
    				} else {
    					c = (char) (str.charAt(i) + vowel);
    				}
    				strBuilder.append(c);
    			}
    		}
    		return strBuilder.toString();
      }
    }
    • public class Encrypt {
    • public static String encryptByVowels(String str) {
    • int vowel = 0;
    • for (int i = 0; i < str.length(); i++) {
    • if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o'
    • || str.charAt(i) == 'u' || str.charAt(i) == 'A' || str.charAt(i) == 'E' || str.charAt(i) == 'I'
    • || str.charAt(i) == 'O' || str.charAt(i) == 'U') {
    • vowel++;
    • }
    • }
    • StringBuilder strBuilder = new StringBuilder();
    • char c = 0;
    • for (int i = 0; i < str.length(); i++) {
    • if (str.charAt(i) == 32) {
    • strBuilder.append(" ");
    • } else {
    • if ((str.charAt(i) + vowel) > 90 && (str.charAt(i) + vowel) < 97) {
    • strBuilder.append("a");
    • c = (char) (96 + ((str.charAt(i) + vowel) % 90));
    • } else if ((str.charAt(i) + vowel) > 122) {
    • strBuilder.append("A");
    • c = (char) (64 + ((str.charAt(i) + vowel) % 122));
    • } else {
    • strBuilder.append((char)(str.charAt(i) + vowel));
    • c = (char) (str.charAt(i) + vowel);
    • }
    • strBuilder.append(c);
    • }
    • }
    • return strBuilder.toString();
    • }
    • }
Code
Diff
  • public class Encrypt {
      
      public static String encryptByVowels(String str) {
        int vowel = 0;
    		for (int i = 0; i < str.length(); i++) {
    			if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o'
    					|| str.charAt(i) == 'u' || str.charAt(i) == 'A' || str.charAt(i) == 'E' || str.charAt(i) == 'I'
    					|| str.charAt(i) == 'O' || str.charAt(i) == 'U') {
    				vowel++;
    			}
    		}
    		
    		StringBuilder strBuilder = new StringBuilder();
    		for (int i = 0; i < str.length(); i++) {
    			if (str.charAt(i) == 32) {
    				strBuilder.append(" ");
    			} else {
    				if ((str.charAt(i) + vowel) > 90 && (str.charAt(i) + vowel) < 97) {
    					strBuilder.append("a");
    				} else if ((str.charAt(i) + vowel) > 122) {
    					strBuilder.append("A");
    				} else {
    					strBuilder.append((char)(str.charAt(i) + vowel));
    				}
    			}
    		}
    		return strBuilder.toString();
      }
    }
    • public class Encrypt {
    • public static String encryptByVowels(String str) {
    • String newS = "";
    • int cont = 0;
    • for(char c: str.toLowerCase().toCharArray()) {
    • if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    • cont++;
    • int vowel = 0;
    • for (int i = 0; i < str.length(); i++) {
    • if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o'
    • || str.charAt(i) == 'u' || str.charAt(i) == 'A' || str.charAt(i) == 'E' || str.charAt(i) == 'I'
    • || str.charAt(i) == 'O' || str.charAt(i) == 'U') {
    • vowel++;
    • }
    • }
    • for(char c: str.toCharArray()) {
    • int newChar = (int) c;
    • if(c != ' '){
    • newChar = c+cont;
    • if(newChar > 90 && newChar < 97)
    • newChar+=(97-newChar);
    • if(newChar > 122) {
    • newChar = 64 + newChar%122;
    • if(newChar > 90 && newChar < 97)
    • newChar+=(97-newChar);
    • }
    • }
    • newS+=""+(char)newChar;
    • StringBuilder strBuilder = new StringBuilder();
    • for (int i = 0; i < str.length(); i++) {
    • if (str.charAt(i) == 32) {
    • strBuilder.append(" ");
    • } else {
    • if ((str.charAt(i) + vowel) > 90 && (str.charAt(i) + vowel) < 97) {
    • strBuilder.append("a");
    • } else if ((str.charAt(i) + vowel) > 122) {
    • strBuilder.append("A");
    • } else {
    • strBuilder.append((char)(str.charAt(i) + vowel));
    • }
    • }
    • }
    • return newS;
    • return strBuilder.toString();
    • }
    • }
Code
Diff
  • public class Encrypt {
      
      public static String encryptByVocals(String str) {
        
        return null;
      }
    }
    • public class Encrypt {
    • public static String encryptByVocals(String str) {
    • return null;
    • }
    • }
public class Encrypt() {
  
  public static String encryptByVocals(String str) {
    
  }
}