Write a program that converts a Roman number such as MCMLXXVIII to its decimal number representation. Hint:
Question:
Write a program that converts a Roman number such as MCMLXXVIII to its decimal number representation. Hint: First write a method that yields the numeric value of each of the letters. Then use the following algorithm:
total = 0
str = roman number string
While str is not empty
If str has length 1, or value(first character of str) is at least value(second character of str)
Add value(first character of str) to total.
Remove first character from str.
Else
difference = value(second character of str) - value(first character of str)
Add difference to total.
Remove first character and second character from str.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Question Posted: