im having a problem with my converter.
this is my code :
void romanNumeral::convert(){
for(int i=0; i < roman.length(); i++){
letter = roman.at(i);
switch(letter){
case 'M':
case 'm': decimal += 1000;
break;
case 'D':
case 'd': decimal += 500;
break;
case 'C':
case 'c': decimal += 100;
break;
case 'L':
case 'l': decimal += 50;
break;
case 'X':
case 'x': decimal += 10;
break;
case 'V':
case 'v': decimal += 5;
break;
case 'I':
case 'i': decimal += 1;
break;
}
}
cout << decimal;
}
is there any way to detect that "iv" is 4 and not 6. and some of the roman numerals like "ix" should be 9 and not 11.