Alien Message Board
/* Alien message board
* Your program takes as input one message board post. A message board post has the following form:
UsernameWithNoSpaces - message that may be multiple words
Example:
Alien25 - ojag qey afoh aoh foghg ^^ ljjls ^^ lsjflsfj!
If there is a Martian swear word in the input, you want to flag the post and the user that posted it. Martian swear words are:
^^
qey
$ */
import java.util.Scanner;
public class Main {
public static void main(String[] args){
// Create the Scanner and read the line of input
Scanner s = new Scanner(System.in);
System.out.println("Enter message board post:");
String inputLine = s.nextLine();
// initialize counter variables to count how many curse words
// parse the string to get each "word" separated by blank spaces
// initially the word is blank, the first word you find will be the name
String word = "";
boolean first=true;
String name="";
// pick out each letter one at a time
for(int i=0;i<inputLine.length();i++){
char letter = inputLine.charAt(i);
// if this is the last letter, add it to the word
if(_____________________________________){
word += letter;
}
// if this is a complete word (letter is a blank space or it's the last letter)
if(________________________________){
// if this is the first word it is the name
if(first){
// you have a word, that's NOT the first word, test to see if it is a curse word
}else{
// if it's a 3 letter word equal to "qey" increment that counter
// if it's a 2 letter word equal to "^^" increment that counter
// if it's a 1 letter word equal to "$" increment that counter
// set the word back to ""
}
}
// otherwise add the letter to the current word
else {
}
}
System.out.println("Results:");
System.out.println();
// if all the counter variables equal 0
if(__________)
System.out.println("CLEAN");
else {
System.out.println("BAD");
System.out.println(name);
System.out.println("qey: "+________);
System.out.println("^^: "+__________);
System.out.println("$: "+__________);
}
}
}