i have hw and i dont know how to solve the Question !!
Roman numbers system has the symbols
I V X L C D M
1 5 10 50 100 500 1000
Roman Numbers are formed by combining the above symbols together and adding the values. For example, MMVI is 1000 + 1000 + 5 + 1 = 2006. Generally:
• Symbols are placed in order of value, starting with the largest values.
• When smaller values precede larger values, the smaller values are subtracted from the larger values e.g. IV is 4, IX is 9, and CM is 900.
• When smaller values follow larger values, the smaller values are added to the larger values e.g. VIII is 8, DX is 510, and LXX is 70.
• The symbols I, X, C, and M can be repeated three times in succession, but no more. (They may appear more than three times if they appear non-sequentially, such as XXXIX.)
• The symbols V, L, and D can never be repeated.
• Only one small-value symbol may be subtracted from any large-value symbol according to the following:
o I can be subtracted from V and X only.
o X can be subtracted from L and C only.
o C can be subtracted from D and M only.
o V, L, and D can never be subtracted.
Write a program that prompts the user to enter a string of symbols representing a Roman number. The program converts that roman number to its equivalent decimal number, and then prints both numbers.
If roman is a variable of type string, then roman[0] stores the first character in the string, roman[1] stores the second character in the string, roman[2] stores the third character in the string, and so on.
Sample input / output:
Enter the Roman Numerial : CCCLXIX
The decimal value of CCCLXIX is : 369