Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner kb= new Scanner (System.in);
- String inputString="";
- inputString=kb.next();
- boolean result=false;
- if (inputString.length() => 3) {
- for (int i=0; i<inputString.length()-3; i++) {
- //Loop how ever many letters there are minus 3 times
- if (inputString.substr(i,1).equals("b") && inputString.substr(i+2,1).equals("a") && inputString.substr(i+3,1).equals("d")) {
- result=true;
- }
- }
- } else {
- result=false;
- }
- System.out.println(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement