Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Screen shot of Java code for your understanding Text format code to copy and execute in your IDE Screen shot of Java code Output Text format code Text... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions

Question

Implement the clone and equals method in the Heap class.

Answered: 1 week ago