Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MyProgram
- {
- public static void main(String[] args){
- System.out.println("enter a sentence");
- Scanner input = new Scanner(System.in);
- String sentence = new String(input.nextLine());
- System.out.println("enter a word that sentence may or may not contain");
- String testString = new String(input.nextLine());
- boolean bruhbool = containsWord(testString);
- if(bruhbool == true){
- System.out.println("the sentence contains that word");
- }
- if(bruhbool == false){
- System.out.println("the sentence does not contain that word");
- }
- }
- public static boolean containsWord (String str){
- if(str.indexOf("disk") >= 0){
- if(str.codePointAt(str.indexOf("disk")-1) != 32 || str.codePointAt(str.indexOf("disk")+4) != 0){
- return false;
- }
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement