Advertisement
Gaudenz

substr

Dec 15th, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | Source Code | 0 0
  1. /*
  2. Unwrapped       = Wrap      == app
  3. Eliminated      = Eliminate == mate
  4. Encrypted       = Crypt     == cry
  5. Drawing         = Draw      == wing
  6. Possibilities   = Possible  == pistol
  7. */
  8.  
  9. public class substr
  10. {
  11.     public static void main(String[] args)
  12.     {
  13.     //INTIALIZATION
  14.     String word1 = "Unwrapped";
  15.     String word2 = "Eliminated";
  16.     String word3 = "Encrypted";
  17.     String word4 = "Drawing";  
  18.     String word5 = "Possibilities";
  19.     //GET ROOT WORD
  20.     String root1 = word1.substring(2,6);
  21.     String root2 = word2.substring(0,9);
  22.     String root3 = word3.substring(2,7);
  23.     String root4 = word4.substring(0,4);
  24.     String root5 = word5.substring(0,6) + word5.charAt(7) + word5.charAt(11);
  25.    
  26.     //MAKE ANOTHER WORD
  27.     String anot1 = word1.substring(4,7);
  28.     String anot2 = word2.charAt(3) + word2.substring(6,9);
  29.     String anot3 = word3.substring(2,5);
  30.     String anot4 = word4.substring(3,7);   
  31.     char anot5[] = {word5.charAt(0), word5.charAt(4) ,word5.charAt(2) ,word5.charAt(9), word5.charAt(1), word5.charAt(7)};
  32.    
  33.     //Converts char to String
  34.     String anotVert = new String(anot5);
  35.    
  36.    
  37.     //OUTPUT
  38.     System.out.printf("\nThe root word of %s    is : %s,    Another word is: %s", word1, root1, anot1);
  39.     System.out.printf("\nThe root word of %s    is : %s,    Another word is: %s", word2, root2, anot2 );
  40.     System.out.printf("\nThe root word of %s    is : %s,    Another word is: %s", word3, root3, anot3 );
  41.     System.out.printf("\nThe root word of %s    is : %s,    Another word is: %s", word4, root4, anot4 );
  42.     System.out.printf("\nThe root word of %s    is : %s,    Another word is: %s", word5, root5, anotVert );
  43.  
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement