CS 1620 Assignment #5 Summer I 1999

Due: Monday June 14, 1999 at midnight
Weight: 8%
Late Penalty: -20% per day late

  1. [25] Write a program that will translate English text into Pig-Latin. English words are converted to Pig-Latin words according to the following rules:
    1. if a word starts with a vowel, just add ay to the end of the word. EG
      • exam becomes examay
      • old becomes olday
    2. if the word starts with a consonant, move all letters, up to the first vowel, to the end of the word and then add ay. EG
      • went becomes entway
      • student becomes udentstay
      • stream becomes eamstray
    3. all other characters should not be changed. EG the sentence
      I have, in the bank, $300 in cash.
      would be translated as
      Iay avehay, inay ethay ankbay, $300 inay ashcay.
    For purposes of this assignment, the vowels are 'a', 'e', 'i', 'o', 'u'.
    The text to be translated is to be read from a file and the output should be written to a file. The program should ask for the filenames at runtime.

    BONUS [3]: When y is not the first letter of a word, it is usually a vowel. Make necessary modifications so that if a y is found inside a word, it is considered a vowel. Thus syllable would be translated yllablesay not ablesyllay but yellow would still be ellowyay.

  2. [25] More conversions
    Your age, on various planets, can be calculated as explained in question 13 on page 133.
    Write a program which asks a user for a person's name, weight and age. It then asks which planet to convert to and prints the person's name along with the weight and age on the chosen planet. Use a MultiInputBox to obtain the input. The input age should be an integer and the output age a floating point formatted with 3 decimal places.
    Note: This program can be done as a modification to last weeks assignment. Modify your converter class, so that it can convert weights and/or ages. Use 3 class arrays to store the names, gravities and number of days in a year for the planets. Modify the controller class so that it uses an array of converters. The index of the array determines which converter to use.

    Use the following to do the conversions:
    Planet NameGravityDays in year
    Mercury0.3888
    Venus0.88225
    Earth1.0365
    Mars0.3687
    Jupiter2.644380
    Saturn1.1510767
    Neptune1.2260225
    Uranus0.9330660
    Pluto0.0690520

Total marks -- 50


Computer Science 1620
Department of Mathematics & Computer Science
University of Lethbridge Home Page