Im working on the following task:
Write a method called normalizeText() which does the following:
-Removes all the spaces from your text
-Remove any punctuation (. , : ; ’ ” ! ? ( ) )
-Turn all lower-case letters into upper-case letters
-Return the result.
The call normalizeText("This is some \"really\" great. (Text)!?"
should return "THISISSOMEREALLYGREATTEXT"
.
Here is what i came up with:
import java.util.Scanner;
public class Crypto {
public static void main(String[] args) {
normalizeText();
}
public static String normalizeText() {
Scanner input = new Scanner(System.in);
System.out.println("Insert your Text : ");
String crypto = input.next();
crypto.replace("\\s", "");
crypto.replaceAll("\\p{Punct}", "");
crypto.toUpperCase();
System.out.println(crypto);
return crypto;
}
}
For every sentence I input, I get just the first word of the sentence printed, without further String changes (Insert your Text : "asdfg asdf asd"
, returns "asdfg"
). As you can see, I'm a beginner and asking for help in the form of hints.