Advertisement
MnMWizard

Remove hi assignment

Dec 23rd, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. //Mason Marnell - remove hi
  2.  
  3. import static java.lang.System.in;
  4. import java.util.Scanner;
  5.  
  6. class removeHi {
  7.  
  8. public static String removehi(String info)
  9. {
  10. if( ! info.contains("hi")) return info; // what happens when info does not contain hi, this is your base caes
  11.  
  12. return removehi(info.replace("hi", "")) ; // remove all "hi" from info and try again
  13. }
  14.  
  15. public static void main(String[] args) {
  16. Scanner keyb = new Scanner(in);
  17. System.out.println("Enter a word and I'll remove all \"hi\"s");
  18. System.out.println(removehi(keyb.nextLine()));
  19. }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement