Here is the scope of my program:
Implement a program that reads a Twitter update (a “tweet”) and prompts the user to provide translations for texting abbreviations within the update. When the user presses the ENTER key by itself to indicate no more translations, the program should display the Twitter update with the translations substituted for the abbreviations. In the displayed Twitter update, for each abbreviation, the abbreviation’s first translation should be followed by the abbreviation within parentheses. In the sample session, notice the “(ru)” following the first “are you” substitution.
The fun (and curse) of Twitter is that messages are limited to 140 characters each. If the user enters a Twitter update longer than 140 characters, your program should process the update up to and including the 140th character and skip any additional characters.
This is the program that I've written, but I keep getting an error
/************************************************ * TweetDecoder.java * Jennifer Stanek * * This program decodes tweets up to 140 characters * based upon user-based corrections *************************************************/ import java.util.Scanner; public class TweetDecoder { public static void main (String[] args) { Scanner stdIn = new Scanner(System.in); String tweet; // User entered tweet String abbreviation = "C"; // abbreviation in tweet that is to be replaced, initialized to begin loop String replacement; // Replaement text for abbreviation System.out.println("Enter a tweet (anything over 140 characters will be cut off):"); tweet = stdIn.nextLine(); if (tweet.length()>140) { tweet = tweet.substring(0,140); // Takes the tweet down to 140 characters } while(!abbreviation.equals("")) // While to continue as long as the input is not empty set { System.out.println("\nEnter abbreviation that is to be replaced (or press ENTER to quit): "); abbreviation = stdIn.nextLine(); //User entered abbreviation that is to be replaced System.out.println("Enter replacement text: "); replacement = stdIn.nextLine (); //User entered replacement for abbreviation replacement = replacement + "(" + abbreviation + ")"; // change replacement to replacement value and original value in parentheses tweet = (tweet.replaceALL(abbreviation, replacement)); // New tweet with specificed charaters replaced }// End While that is chekcing for empty set System.out.println("/nHere is your translated tweet:/n" + tweet); // Prints out new tweet } // End Main } // End class TweetDecoder
C:\Users\Jennifer\Documents\school\TweetDecoder.java:33: error: cannot find symbol tweet = (tweet.replaceALL(abbreviation, replacement)); // New tweet with specificed charaters replaced ^ symbol: method replaceALL(String,String) location: variable tweet of type String 1 error Tool completed with exit code 1
I can not figure out what I'm doing wrong. To be fair, the book's examples of replaceALL were horrible, but I thought I was using it correctly. Any help would be appreciated.