RU beehive logo ITEC dept promo banner
ITEC 120
2008fall
aaray,
ejderrick,
ibarland,
jmdymacek

homeinfolabshwsexams
textbookjava.lang docsjava.util docsarchive

hw08
Translating many words

Due Nov.12 (Wed).

This is an individual homework: Although it uses work from lab09b—Pig La(b)tin I (If you want it, here is a pig-latin solution, as given-and-fixed-up in lab10b—debugging), you are not to work with your lab partner. (As ever, you can discuss the problem and approaches with others, but you have to write the code entirely on your own.)

For this assignment, we'll write a program which translates an entire message into Pig Latin. We'll start with the file we wrote in lab09b—Pig La(b)tin I, and add more methods to it. (Be sure you got a copy of that file which you and your lab partner worked on; alternately, a solution will be provided here soon.)

By the way, we will not duplicate code from that program; instead, we'll repeatedly call that method to translate a single word. Ere'shay owhay:

Extra credit options

There are many ways to improve this assignment. We'll offer some extra-credit, but don't start working on these until you have your regular program fully working. You can do any of these options; you don't need to do A before trying B, etc..

  1. Extra credit: handle capital letters correctly.
  2. Extra credit: Handle punctuation better: if you are translating a word which ends in punctuation character3, place the 'ay' before the punctuation. That is, “dang!” should translate to “angday!”, instead of “ang!day”.
  3. Extra credit: if a word has multiple punctuation characters, do something reasonable. (Two approaches that seem reasonable to me: “System.err.println...gesundheit!” might be translated into “ystemSay.err.println...gesundheit!”, or (for extra cool awesomeness) it might be translated into “ystemSay.erray.intlnpray...esundheitgay!”.
  4. Challenge Extra credit: Write a method which can translate a web page into pig latin.
    It takes two Strings as input — the URL to read from, and the name of a file to write the translated html to.

    It turns out, having a scanner read from a web page (rather than System.in) is easy. However, web pages are more than just words of text; web pages contain markup to indicate the structure of the document (where emphasized text should start and end, where to insert horizontal lines, etc.). Thus, web pages are written in “HTML” — “hypertext markup language”. We need to translate the regular information into pig latin, but leave this markup information untouched.

    More information you need is here.


1 Doing this would require something fancier than Scanner's next(): perhaps calling nextLine(), and then reading information from that String by creating a (second) Scanner which gets its input not from the keyboard, but from that String.      

2 The user can indicate end-of-input by typing typing Control-D on a line by itself. Note that the Scanner method hasNext usually returns true; it only returns false when the input is finished (that is, when the user has typed control-D).      

3 For this extra credit, we won't consider (or worry about) words which have more than one punctuation character.      

homeinfolabshwsexams
textbookjava.lang docsjava.util docsarchive


©2008, Ian Barland, Radford University
Last modified 2008.Nov.20 (Thu)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme