Question: Write a program that prompts for a line of text and then transforms the text based on chosen actions. Actions include reversing the text and

Write a program that prompts for a line of text and then transforms the text based on chosen actions. Actions include reversing the text and converting the text to leet-speak. You may be able to imagine extending to other actions such as a pig-latin translator, or encoding or decoding a secret message. Turn in the version specified here before extending.

Welcome to the Text Converter.

Available Actions:

1337) convert to 1337-speak

rev) reverse the string

quit) exit the program

Please enter a string: Hello CS 200.

Action (1337, rev, quit): rev

.002 SC olleH

Action (1337, rev, quit): reverse again

Unrecognized action.

.002 SC olleH

Action (1337, rev, quit): rev

Hello CS 200.

Action (1337, rev, quit): quit

See you next time!

All input is followed by a newline, resulting in the next prompt being on the following line. The last line, "See you next time!", is also followed by a newline (Which this presentation tool removes, unfortunately.)

Write three methods: main, action1337 and actionReverse. All input and output are completed in the main method. Based on the action the user chooses, call the appropriate action method. If an unrecognized action is entered then the message "Unrecognized action." should be shown on a line by itself and then the user is prompted again just as they were when an action was performed.

/**

* 1337 — convert the string to leet-speak:

* Replace each L or l with a 1 (numeral one)

* Replace each E or e with a 3 (numeral three)

* Replace each T or t with a 7 (numeral seven)

* Replace each O or o with a 0 (numeral zero)

* Replace each S or s with a $ (dollar sign)

*

* @param current Original string

* @return string converted to leet-speak.

*/

public static String action1337(String current) {

return null; //FIX ME

}

/**

* This reverses the order of characters in the current string.

* @param current Original string to be reversed.

* @return The string in reversed order.

*/

public static String actionReverse(String current) {

return null; //FIX ME

}

/**

* Provides the main menu for the text converter and calls methods based

* on menu options chosen.

* @param args

*/

public static void main(String[] args) {

//FIX ME

}

An algorithm for the main method is:

Show Welcome message and menu

Prompt for text string

Loop until "quit"

Prompt for action

Call appropriate action method

End Loop

Step by Step Solution

3.39 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To accomplish this programming task we need to implement a Java program that performs the described text transformations Specifically we need to compl... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!