Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java application that acts as a one-word Pig Latin translator. Your program should: ask the user to enter a word convert the entered

Write a java application that acts as a one-word Pig Latin translator. Your program should: ask the user to enter a word convert the entered word into proper Pig Latin translation print the translated word on the screen. The rules for pig latin translation are as follows: Rule #1: Words that start with a vowel (A, E, I, O, U) should simply have the characters "way" appended to the end of the word. For example, the word "apple" translates into "appleway" 'Y' is not counted as a vowel for this rule. Rule #2: Words that start with a consonant should have all consonant letters up to the first vowel moved to the end of the word and then "ay" is appended. For example, the word "chair" translates into "airchay" 'Y' is considered to be vowel in this rule, so the word "xylophone" translates into "ylophonexay" It is possible that the word may not contain any vowels at all. In this case, following rule #2, you would simply append "ay" to the end of the word. For example, the word "crwth" translates into "crwthay" Rule #3: When "Y" is the first letter of the word, the word should follow Rule #2. As an example, the word "yellow" translates into "ellowyay" Program Requirements The user should enter all lowercase letters. If the user enters any uppercase letters, you should convert to all lowercase before proceeding. Additionally, also remove any spaces that the user may enter at the beginning or end of the word. There are methods in the String class to do both of these tasks. The main program should only do three basic things: Get the input from the user Use a method named translate to get the Pig Latin translation of the input word Print the result to the screen The main program is NOT allowed to do any String processing that is the job of the translate method. The main program should only do the three things listed above. You must write and use a method called translate. This method should NOT get any values from the user/keyboard that job should be done by the main program. This method should be sent a String value from the main program. This string is the word which should be translated into Pig Latin. The method, then, should create a new string (you will need a local variable to hold this string temporarily). This new string will be the translation of the original word. Finally, this method will need to send the new string back to the main program so that the main program can print the final result. The translate method is NOT allowed to print anything to the screen. Declare the keyboard object as a class (global) variable as discussed in our class example. You are NOT allowed to use any other class (global) variables in this program. All other variables must be declared as local.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

3. Develop a case study.

Answered: 1 week ago