COMP2004 Programming Practice
2002 Summer School

Assignment 1 - Roman Numeral Converter


Summary

DUE DATE: 5:00pm Tuesday 15 January 2002 (extension announcement)
WEIGHT: 10%
SUBMISSION NAME: comp2004s.a1
MARKING TYPE: automated testing and hand marking
TASK: Write a program to convert integers to Roman numerals

Detailed Description

Common Questions

  1. How many symbols will there be?
    There will be an odd number of symbols between 3 and 19 (inclusive).

  2. What if this isn't the case?
    It will always be the case in the machine marking. Thus it doesn't matter what your code does if it isn't the case.

  3. What if symbols are repeated in the symbol list, eg IVXLCDMIV?
    That won't be tested, so you don't need to worry about it. However, that said, your code should probably still work, it's just that the output will be ambigious (ie. if you look at the output and see one of the repeated symbols, you won't necessarily know which value it represents).

  4. What's the maximum integer which will be input?
    Each integer will be between 1 and ULONG_MAX. ULONG_MAX is the maximum number which can be stored in a variable of type unsigned long. On the ugrad systems, this is 232-1 = 4294967295, but this number doesn't actually mean much on its own - the key idea is to use unsigned long variables whenever you might need to store a number which is this large.

  5. My program reads and converts one integer and then exits. Is this okay?
    No. Your program needs to read as many integers as there are in the input. If you only read and convert one integer, you'll probably get no machine marks. Have a look at the Week 2 Monday lecture for how you might go about doing that in main().

  6. Okay, I've got the standard while (std::cin >> number) code. How do I stop the input when I'm testing my code?
    If you're on Unix (eg. the Basser labs) or Cygwin, type Ctrl-D (on a blank line). If you're using some form of DOS/Windows compiler, try typing Ctrl-Z (on a blank line). In both cases, this causes end-of-file to be registered on std::cin, which makes the above while loop exit.

  7. Does the machine marking read from files? If so, do we have to take our input from files?
    In fact, the machine marking does read from files. However, it feeds these files into your program in such a way that your program still thinks that its input is being typed in by a human. Thus, you can read from std::cin as normal and not worry about reading from files in your program.

  8. Should I output each Roman numeral as I read in the integer, or should I read all the integers first and then output all the Roman numerals?
    The machine marking doesn't distinguish between these two cases. However there doesn't seem to be any real point in storing all the integers just to convert and output them later, unless you like wasting memory.