function romToDec (roman$) num = 0 prenum = 0 for i = length(roman$) to 1 step -1 x$ = mid(roman$, i, 1) n = 0 if x$ = "M" then n = 1000 if x$ = "D" then n = 500 if x$ = "C" then n = 100 if x$ = "L" then n = 50 if x$ = "X" then n = 10 if x$ = "V" then n = 5 if x$ = "I" then n = 1 if n < preNum then num -= n else num += n preNum = n next i return num end function #Testing print "MCMXCIX = "; romToDec("MCMXCIX") #1999 print "MDCLXVI = "; romToDec("MDCLXVI") #1666 print "XXV = "; romToDec("XXV") #25 print "CMLIV = "; romToDec("CMLIV") #954 print "MMXI = "; romToDec("MMXI") #2011