Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1.  
  2. public class StringHelper {
  3. private String str;
  4.  
  5. public StringHelper() {
  6. }
  7.  
  8. public static String meshStrings(String str1, String str2) {
  9. String mesh_str = "";
  10.  
  11. for(int i = 0; i < str1.length(); i++) {
  12. mesh_str += str1.charAt(i);
  13.  
  14. if (str2.length() > i) {
  15. mesh_str += str2.charAt(i);
  16. }
  17. }
  18.  
  19. if (str2.length() > str1.length()) {
  20. mesh_str += str2.substring(str1.length());
  21. }
  22.  
  23. return mesh_str;
  24. }
  25.  
  26. public static String replaceVowelsWithOodle(String str) {
  27. String new_str = "";
  28.  
  29. for(int i = 0; i < str.length(); i++) {
  30. char c = str.charAt(i);
  31. if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' || c == 'U' ) {
  32. new_str += "oodle";
  33. } else {
  34. new_str += c;
  35. }
  36. }
  37.  
  38. return new_str;
  39. }
  40.  
  41. public static double weight(String str) {
  42. double weight = 0.0;
  43.  
  44. for (int i = 0; i < str.length(); i ++) {
  45. char c = str.charAt(i);
  46. if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' || c == 'U' ) {
  47. weight += 2.5;
  48. } else {
  49. weight += 3.4;
  50. }
  51. }
  52.  
  53. return weight;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement