Project 1: Latin to English Translator

CSE 143
Summer 1998

For this assignment, you will provide implementations for three functions. The first will read a roman numeral from an input stream and write a string containing that numeral into a buffer. The second will take a string representing a roman numeral and return the integer represented by that numeral. The third will take an integer and write a string containing the english representation of that integer into a buffer. Putting these functions together, you will construct a program that reads in roman numerals and prints out the english equaivalent, producing a very limited Latin to English Translator.

This assignment will emphasize meeting a specification. You should not think of the Latin to English Translator as the final product; instead, consider the three functions you write as the programming goal. Since these functions may be used to read the output from another program, or produce text to be used as input for another program, it is important to conform to the specification you are given. Similarly, since any of these functions could be incorporated into another program, it is important not to change the number of parameters, the types of the parameters, or the return value.

Roman numerals

Before you can write the first two functions, you need to know what a roman numeral is. If you are not familiar with them, then the Roman Numerals 101 site is a good place to look.

For this assignment, you need only read in roman numerals consisting of the following characters: I, V, X, L, C, D, and M (that is, you will not need to read in characters with bars over them, or lowercase, or alternate forms of letters). Also, while there are sometimes multiple acceptible representations of the same number (four can be represented as IV or IIII) you need only read in the short form (IV). The largest number you will be expected to read in is 9999, or in roman numerals, MMMMMMMMMCMXCIX. The longest number you will be expected to read in is MMMMMMMMMDCCCLXXXVIII, or 9888. The length of this numeral is given by the const int MAX_ROMAN_LEN.

English text

English forms of numbers will conform to the following specifications:

  1. Letters will be all lowercase. The roman numeral 'I' should be translated to 'one'; 'One' and 'ONE' are incorrect.
  2. The words for the numbers 21-29, 31-39, etc. are hyphenated. The roman numeral XXIII should be translated as 'twenty-three'; 'twenty three' and 'twentythree' are incorrect.
  3. All other words in the english representation are separated by a single space, without the use of the word 'and'. The roman numeral DIII should be translated as 'five hundred three'; 'fivehundred three' and 'five hundred and three' are incorrect.
  4. Thousands must be printed separately from hundreds. The roman numeral 'MCMXCVIII' should be translated to 'one thousand nine hundred ninety-eight'; 'nineteen hundred ninety-eight' is incorrect.

The following list contains the proper spellings of all words you will need (counting hyphenated words as two rather than one): zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, thirty, fourty, fifty, sixty, seventy, eighty, ninety, hundred, thousand

There are multiple longest strings of english text you will need to generate; one such string is "seven thousand seven hundred seventy-seven". The length of this string is given by the const int MAX_ENGLISH_LEN.

Detailed Specification

  1. Program organization: Your project will consist of 5 files. Three of these we have supplied, and cannot be changed:

    You will provide two files, roman.cpp which implements the functions in roman.h, and inttoeng.cpp which implements the function in inttoeng.h.

  2. Functions on roman numerals: You will provide the implementations for the following functions apropos roman numerals: These two functions should reside in roman.cpp.

  3. Functions on english text: You will provide the implementation for this function: This function should reside in inttoeng.cpp.

  4. Other functions: You are free to define your own helper functions inside roman.cpp and inttoeng.cpp. But these functions should be used only by the file in which they reside. And you may not redefine the function prototypes we have given you above.

Executable

To verify that your solution is working correctly, we encourage you to compare it against our sample solutions. The following links will allow to download sample Windows and x86 Linux executables.

Always make sure to test your program against a variety of inputs! Roman numerals and English text were chosen for this assignment partly because they have some special cases that must be dealt with. Try enough different inputs that you are confident your program behaves correctly on all inputs.

Turn-In

Homework 1 is due on Monday, July 6th, 1998, at 5:00pm. You will turn in your homework using a form on the course web, and you will be unable to submit your homework after 5:00pm. Please plan your time so that you will not be trying to submit your assignment at 4:59.

When you're finished writing your solution, you can use the electronic turn-in form to submit it. Follow the instructions on that form (especially with regards to file naming conventions), print the receipt, and submit the receipt at the start of section, Tuesday, July 7th, 1998. For full credit, you must turn in electronically, print the receipt, and hand in that receipt in your section. You may also be able to drop your receipt in the drop box located on the first floor of Sieg hall, across from room 127. More details on this will follow.

If You Get Stuck

If you're having problems, there are a number of resources available for you.

If you need help with the lab environment or the online resources, go talk to a consultant in the IPL. I also encourage you to work through Homework 0, designed to get you up to speed on these issues.

If you can't make progress in the actual assignment, please talk to the instructor or a TA. They are available during posted office hours, and sometimes by appointment. They will also occasionally help you out over email. You are invited to seek help from any available TA, not just your own.

You can discuss the assignment in general terms with other students. You can ask general questions on the student discussion list for this course, cse143@cs. But any code you write must be your own. For more details about what is and is not allowed, see the Software hygiene page.


cse143-webmaster@cs.washington.edu