-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfanity_check.java
More file actions
52 lines (52 loc) · 1.19 KB
/
Copy pathProfanity_check.java
File metadata and controls
52 lines (52 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.Scanner;
public class Profanity_check{
static String str(String[] a){
String s="";
for(int i=0;i<a.length;i++){
s+=a[i];
}
return s;
}
static boolean frm(int from,String word, String[] b){
char[] a=word.toCharArray();
boolean see=false;
String n="";
for(int f=from;f<word.length();f++){
n+=a[f];
if(exist(b,n)==true){
see=true;
}
}
return see;
}
static boolean exist(String[] a, String word){
boolean ex=false;
for(int x=0;x<a.length;x++){
if(a[x].equals(word)){
ex=true;
}
}
return ex;
}
public static void main(String[] args){
Scanner inp=new Scanner(System.in);
while(true){
System.out.print("message:");
String message=inp.nextLine();
String check_this=str(message.split(" "));
String[] p={"fuck","idiot","dumb","stupid","asshole","jerk","choach","ass","shit","uwu","BTS","Nightcore","air"}; //list of bad words, you can add words here.
boolean check=false;
for(int n=0;n<check_this.length();n++){
if(frm(n,check_this,p)==true){
check=true;
}
}
if(check==true){
System.out.println("The word you entered is not allowed.");
}
else{
System.out.println("word successfully entered!");
}
}
}
}