45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
import java.util.Scanner;
|
|
|
|
public class txt_msg_expander {
|
|
|
|
public static String replaceText(String input,
|
|
String replaceThis,
|
|
String withThis) {
|
|
System.out.println("Replaced \"" +replaceThis + "\" with \"" +
|
|
withThis + "\"");
|
|
return input.replace(replaceThis, withThis);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Scanner scnr = new Scanner(System.in);
|
|
|
|
System.out.println("Enter text:");
|
|
String usr_input = scnr.nextLine();
|
|
System.out.println("You entered: " + usr_input+"\n");
|
|
|
|
if (usr_input.contains("BFF")){
|
|
usr_input = replaceText(usr_input, "BFF", "best friend forever");
|
|
}
|
|
|
|
if (usr_input.contains("IDK")){
|
|
usr_input = replaceText(usr_input, "IDK", "I don't know");
|
|
}
|
|
|
|
if (usr_input.contains("JK")){
|
|
usr_input = replaceText(usr_input, "JK", "just kidding");
|
|
}
|
|
|
|
if (usr_input.contains("TMI")){
|
|
usr_input = replaceText(usr_input, "TMI", "too much information");
|
|
}
|
|
|
|
if (usr_input.contains("TTYL")){
|
|
usr_input = replaceText(usr_input, "TTYL", "talk to you later");
|
|
}
|
|
|
|
System.out.println("\nExpanded: " + usr_input);
|
|
|
|
scnr.close();
|
|
}
|
|
}
|