SHARE
TWEET

Untitled

a guest Dec 8th, 2019 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.lang.StringBuilder;
  2. import java.lang.Math;
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.  public static String duplicate(String str) {
  8.      
  9.      String answer = "";
  10.      int n = 0;
  11.      
  12.      if (str.length() % 2 == 0) {
  13.          n = str.length() * 2;
  14.      } else {
  15.          n = str.length();
  16.      }
  17.      
  18.      for (int i = 0; i < str.length(); i++) {
  19.          
  20.          for (int j = 0; j < n; j++) {
  21.           answer = answer + str.charAt(i);  
  22.          }
  23.          
  24.          
  25.      }
  26.  return answer;
  27.      
  28.  }
  29.  
  30.  public static Double numberScramble(Double num) {
  31.      
  32.      if (num < 0) {
  33.          return 0.0;
  34.      }
  35.      
  36.      num = num + 5;
  37.      num = num / 2;
  38.      num = Math.sqrt(num);
  39.      return num;
  40.      
  41.  }
  42.  
  43.  public static Boolean isEdhesivePalindrome(String str) {
  44.  
  45.      
  46.      if (str.length() > 15 || str.length() < 3) {
  47.          return false;
  48.      }
  49.      
  50.      str = str.toLowerCase().replace('a', '4').replace('e', '3').replace('o', '0');
  51.          
  52.         StringBuilder reverse = new StringBuilder(str);
  53.         String reversestring = reverse.reverse().toString();
  54.        
  55.         if (str.equals(reversestring)) {
  56.             return true;
  57.         }  else {
  58.             return false;
  59.         }
  60.      
  61.  }
  62.  
  63.  public static void main(String[] args) {
  64.      System.out.println("Welcome to the Methods Sampler Platter. Please enter a String to duplicate.");
  65.      Scanner scan = new Scanner(System.in);
  66.      String input = scan.nextLine();
  67.      System.out.println("The duplicated String is: " + duplicate(input));
  68.      System.out.println("Next, please enter a String to check for Edhesive Palindromes.");
  69.      String pali = scan.nextLine();
  70.      
  71.      if (isEdhesivePalindrome(pali) == true) {
  72.          System.out.println("Nice, you found an Edhesive Palindrome!");
  73.      } else {
  74.          System.out.println("Too bad, that isn't an Edhesive Palindrome.");
  75.      }
  76.      System.out.println("Almost done! Please enter a number to scramble.");
  77.      double scramble = scan.nextDouble();
  78.      System.out.println("The scrambled number is: " + numberScramble(scramble));
  79.      scan.close();
  80.  }  
  81.    
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top