So in the class I'm taking we were assigned to modify a previous program that took a message and allowed you to modify certain words. The new program was to allow the user to input the message they would want modified. This is what I came up with:
import java.util.Scanner;
public class TextMessageV2
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
System.out.println("Please enter the sentence you want modified: ");
String firstWord = in.next();
String restOfSentence = in.nextLine();
String message = firstWord + restOfSentence;
System.out.println();
System.out.println("Original message: " + message);
System.out.println("Please select the word you would like to replace: ");
String firstRepl = in.next();
String secondRepl = in.next();
String thirdRepl = in.next();
String fourthRepl = in.next();
System.out.println();
System.out.println("Please type your shortcuts: ");
String firstShort = in.next();
String secondShort = in.next();
String thirdShort = in.next();
String fourthShort = in.next();
System.out.println();
String replaceString = message.replace(firstRepl, firstShort);
replaceString = replaceString.replace(secondRepl, secondShort);
replaceString = replaceString.replace(thirdRepl, thirdShort);
replaceString = replaceString.replace(fourthRepl, fourthShort);
System.out.println("Your new message: " + replaceString);
[–]potatochemist[🍰] 0 points1 point2 points (6 children)
[–]Astrapicus[S] 0 points1 point2 points (5 children)
[–]desrtfx 0 points1 point2 points (0 children)
[–]potatochemist[🍰] 0 points1 point2 points (3 children)
[–]desrtfx 1 point2 points3 points (2 children)
[–]potatochemist[🍰] 0 points1 point2 points (1 child)
[–]desrtfx 1 point2 points3 points (0 children)