Advertisement
Slyke

Untitled

Sep 14th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Scanner kb= new Scanner (System.in);
  2.  
  3. String inputString="";
  4. inputString=kb.next();
  5.  
  6. boolean result=false;
  7.  
  8.  
  9. if (inputString.length() => 3) {
  10.   for (int i=0; i<inputString.length()-3; i++) {
  11.   //Loop how ever many letters there are minus 3 times
  12.     if (inputString.substr(i,1).equals("b") && inputString.substr(i+2,1).equals("a") && inputString.substr(i+3,1).equals("d")) {
  13.       result=true;
  14.     }
  15.  
  16.   }
  17. } else {
  18.   result=false;
  19. }
  20. System.out.println(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement