CSE-1020: Introduction to Computer Science I
York University
Lab Test #1: IxNay
2:30pm Monday 16 November 2009
(Lab-01)
  Welcome to the Lab-test Environment

During the test, you will not be able to access your regular home directory, access, receive, or send e-mail, print, or access the Internet.

The lab tests are closed-book and no aids are allowed.

At the end of your test session, this machine will be converted back to a standard, unrestricted Prism Lab machine. At this time, any files written by you during the test, except those that have been submitted, will not be recoverable. Make sure you submit your code before the end of the test. (Instructions to submit your code are below). If you do not submit your work on time, you will receive a grade of zero. (There are no exceptions.)

Instructions

You have the lab period, 80 minutes, to complete this lab test. The computers will automatically shutdown at the end of the time (e.g., 3:50pm), warning you several minutes in advance. No additional time will be provided, so you must submit your work prior to this; otherwise, there will be no way to recover it (it will be lost), and you will receive a grade of zero (no exceptions).

You are encouraged to submit often during the test. Note that newer submissions overwrite older ones.

Your program will be marked for good style, as well as for running correctly (producing correct output in the correct format).

Submitting Your Work

When you submit a file, you should include at the top of the file your name (surname, given name) and your Prism lab login. These should be placed in a comment so that the file will compile. Note that files which do not compile will receive a large penalty when marked, no matter how small the error that prevented compiling.

Submit the class IxNay.java before the time deadline. Here is the command to submit your work:

% submit 1020 labtest2M2.30 IxNay.java

Further details regarding the submit command can also be obtained by typing man submit.

Once again, you are encouraged to submit regularly. Newer submissions simply overwrite older ones.

Unlike eCheck assignments, there is partial credit possible. If you are able to finish all aspects of the program (for example, say, input validation was requested but you did not do this), you should still submit it.

Useful APIs

Here are the common APIs that you may access:

 
  The Task

Write a Java application called IxNay.java. Your app should ask repeatedly the user to input a line of text, until the user enters Ctrl-D to indicate the end of input. It then converts the text into ix-nay, also called pig latin, and prints it out.

Ix-nay encodes words in a silly way, making it some degree harder for people who do not know the code to understand a conversation. It encodes words in the following way.

  • If a word begins with consonants (the non-vowel letters), all the initial consonants are moved to the end of the word and "ay" is added. For example, "String" becomes "ingSTRay".
  • Otherwise (the word begins with a vowel), "yay" is added. For example, "indexOf" becomes "indexOfYay".

Generate your output as shown in the sample runs below. Parse each line and convert it into ix-nay.

  • Consider a word to be a contiguous stretch of letters ([a-zA-Z]+).
  • Leave all punctuation and spacing as in the input. (Your app is just converting each word.)
  • Leave all capital letters as in the input, except capitalize all consonants that are moved to the end of each word.
  • For words starting with a vowel, add "Yay" (so with a capital "Y").
  • Consider a, e, i, o, and u to be the vowels, and all other letters to be consonants.

After the user has ended input (with Ctrl-D), the app should print Done.

Hints

Consider the methods matches and substring in class java.lang.String. The regex "[aeiouAEIOU]+" matches a substring of vowels, and "[a-zA-Z]+" matches a word (as defined here), and "[^a-zA-Z]+" matches a substring of non-letter characters.

If you have difficulty processing the entire sentence, try processing single words instead for part credit.

Sample Runs

Here is a sample run of a correctly written program. Note that the text in red is text that the user types. The text in black is what the program types. (Italics is for clarifying comments, and do not appear in the input or output.) The '%' represents the prompt from the command-line window (shell).

% java IxNay
Enter a sentence:
Java, the programming language, is great!!
avaJay, eTHay ogrammingPRay anguageLay, isYay eatGRay!!
Enter a sentence:
?This lab test is quite easy.
?isTHay abLay estTay isYay uiteQay easyYay.
Enter a sentence:
  Is my program ?working?  correctly, I wonder?
  IsYay MYay ogramPRay ?orkingWay?  orrectlyCay, IYay onderWay?
Enter a sentence:
Ctrl-D (Note that you will not actually see this appear on the screen when typed.)
Done.
%
Coding

You should use good programming practises as described in the textbook, and your code should conform to the style guide in the textbook. You should comment at least minimally, as by the guidelines.

You should not use any features of Java not covered in the first six chapters of the text. There will be some deduction if you do.