Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete class called PigLatinTranslator that has the following: 1. (8 points) main method: a. Prompts the user for the name of the input

Write a complete class called PigLatinTranslator that has the following:

1. (8 points) main method:

a. Prompts the user for the name of the input file (of the form *.txt a text file located in the same folder as your program)

b. Creates a Scanner object for reading from that file.

c. Creates a PrintStream object for writing (the translated text) to an output file. Name the output file by adding PL to input file name. So if the input file name is original.txt, output file should be called original-PL.txt. d. Calls the method pigLatin passing the Scanner and the PrintStream objects.

2. (18 points) pigLatin method: that accepts two objects as parameters- one of type Scanner for reading the input file and one of type PrintStream for writing the output file. Your method should write out the input file's text in a simplified version of Pig Latin, a silly English variant where the first letter of each word is moved to the end. Our rules for translating a word to Pig Latin are listed below.

This method a. (2 points) Should preserve line breaks from the original file, but removes extra spaces between words on the same line.

b. For each word: i. (3 points) Convert to lower case and remove following punctuations: period (.), comma (,), question mark (?) and exclamation (!) Assume that these will be the only non-alphabetical characters in the input sentences, and these will appear as part of a word at the end of the word (not by themselves) ii. (10 points) Translate to Pig Latin version using the rules given below.

c. (3 points) Write the sentence to the output file. 3. (4 points) - Include appropriate program documentation and formatting including: Your first and last name, the date of submission, code comments necessary to explain the operation of your program, and proper indentation of the code, etc. Pig Latin Translation Rules: If the word starts with a vowel, just add way to the end of the word. For example, o are becomes areway o in becomes inway If the word starts with a consonant, move all of the consonants that appear before the first vowel to the end of the word, and then add ay to the end of the word. For Example, o word becomes ordway (ord + w+ ay) o student becomes udentstay (udent + st + ay) o road becomes oadray (oad + r + ay) Note: There are no official rules for Pig Latin. Most people agree on how words that begin with consonants are translated, but there are many different ways to handle words that begin with vowels. For this assignment, stick to the above rules. Read the description above closely to understand what is expected of your program. Use methods to organize your code better. Make sure your program can find the input file correctly. Different IDEs may behave differently in this regard. See the sample run with the original and translated text shown below. Contents of original.txt: First sentence and more. Second sentence and more. Third one here is very nice. What do you say? Fifth one is even better. Great! Great! Great! Contents of original-PL.txt after the program runs: irstfay entencesay andway oremay econdsay entencesay andway oremay irdthay oneway erehay isway eryvay icenay atwhay oday ouyay aysay ifthfay oneway isway evenway etterbay eatgray eatgray eatgray

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Explain Industrial market segment.

Answered: 1 week ago

Question

Explain the market segmentation.

Answered: 1 week ago

Question

=+j Explain the relationship between unions and MNEs.

Answered: 1 week ago

Question

=+Have they changed the way employees view IP?

Answered: 1 week ago