|
|
You are to design and implement a Roman numeral calculator. The subtractive Roman numeral notation commonly in use today was used only rarely during the time of the Roman Republic and Empire. For ease of calculation, the Romans most frequently used a purely additive notation in which a number was simply the sum of its digits (4 equals IIII in this notation, not IV). Each number starts with the digit of highest value and ends with the digit of smallest value. This is the notation you will use in this program. Your program inputs two Roman numbers and an arithmetic operator and prints out the result of the operation, also as a Roman number. The values of the Roman digits are as follows: I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Thus, the number MDCCCCLXXXXVI represents 1996, because 1996 really consists of: 1000 + 500 + 100 + 100 + 100 + 100 + 50 + 10 + 10 + 10 + 10 + 5 + 1. M D C C C C L X X X X V I The arithmetic operators that your program should recognize in the input are +, -, *, and /. These should perform the C++ operations of integer addition, subtraction, multiplication, and division. One way of approaching this problem is to convert the Roman numbers into integers, then perform the required operation, and then convert the result back into a Roman number for printing. Assume that the input numbers are in purely additive form - that is, digits are followed only by digits of the same or lower value. Also assume that the letters are all legal, no need to check for errors in the input file. Also, assume that the answer to each calculation will be a positive number. |