Antique Formatting ------------------ You have been asked to write prototype a formatting function. As a test your program is to read a format- ting string and some arguments, and apply the formatting string to the arguments. You boss, however, is a bit on the antique side. The formatting string is a sequence of commands, each of which is a single character. For the prototype, only two commands are implemented: w Print the next argument as a string of words. i Print the next argument as an integer, treating the formatted integer as one word. However, as we said, your boss is antique. Words are to be printed from right to left in the output. An integer is to be printed as a Roman numeral word. For this prototype, each formatting string produces one line of output, with words separated by single spaces, and no other spaces in the line. More specifically, the words in a `w' string are separa- ted by single spaces, but these spaces are discarded after extracting the words. The order of the words in the string is the reverse of the order of the words in the output line. However, the letters within a printed word are in the same order as the letters within the word in the string. So word order is reversed but letter order is not. Roman numerals use the following letters to represent numbers: I 1 V 5 X 10 L 50 C 100 D 500 M 1000 There is no way to represent zero, and you will not be asked to print zero. The first 10 numbers are encoded as: I 1 II 2 III 3 IV 4 (-1 + 5) V 5 VI 6 VII 7 VIII 8 IX 9 (-1 + 10) X 10 Your boss wants you to simply encode the digits of the integer using the encodings just given. For the tens digit you simply make the replacements: I --> X V --> L X --> C and for the hundreds digit I --> C V --> D X --> M You will not be asked to print any number larger than 3999, which allows you to use M, MM, or MMM for the thousands digit. Note the order that digits are printed in is the same for decimal and our Roman numerals. The thousands digit is printed before the hundreds digit, etc. For example, 1999 is printed as MCMXCIX, and 1849 as MDCCCXLIX. Input ----- For each test case, one line containing the name of the test case, followed by one line containing the format- ting command string, followed by one line for each argument containing just the argument, followed by an empty line. Input integers are represented in decimal, and are in the range from 1 to 3,999. Input ends with an end of file. Output ------ For each test case, one line containing the name of the test case, followed by the output line for that test case. No output line will be longer than 80 characters. Sample Input ------ ----- TEST-1 wiw we want 4 words TEST-2 iwiwi 2 plus 2 equals 4 TEST-3 wi a good year is 1999 TEST-4 wi another year is 1849 TEST-5 wi the last year of the millennium is 2000 [Note the last line of the input is empty.] Sample Output ------ ------ TEST-1 words IV want we TEST-2 IV equals II plus II TEST-3 MCMXCIX is year good a TEST-4 MDCCCXLIX is year another TEST-5 MM is millennium the of year last the File: antique.txt Author: Bob Walton Date: Wed Oct 10 12:05:13 EDT 2007 The authors have placed this file in the public domain; they make no warranty and accept no liability for this file. RCS Info (may not be true date or author): $Author: walton $ $Date: 2007/10/10 16:05:57 $ $RCSfile: antique.txt,v $ $Revision: 1.5 $