public static int expandRoman(String roman){
  int value=0;
  for (int p=0; p < roman.length(); p++) {
    char c=roman.charAt(p);
    if (c == 'X') {
      value+=10;
    }
 else     if (c == 'V') {
      value+=5;
    }
 else     if (c == 'I') {
      if (p + 1 < roman.length()) {
        char p1=roman.charAt(p + 1);
        if (p1 == 'V') {
          value+=4;
          p++;
        }
 else         if (p1 == 'X') {
          value+=9;
          p++;
        }
 else {
          value+=1;
        }
      }
 else {
        value+=1;
      }
    }
  }
  return value;
}

public static int expandRoman ( String roman ) { int value = 0 ; for ( int p = 0 ; p < roman . length ( ) ; p ++ ) { char c = roman . charAt ( p ) ; if ( c == 'X' ) { value += 10 ; } else if ( c == 'V' ) { value += 5 ; } else if ( c == 'I' ) { if ( p + 1 < roman . length ( ) ) { char p1 = roman . charAt ( p + 1 ) ; if ( p1 == 'V' ) { value += 4 ; p ++ ; } else if ( p1 == 'X' ) { value += 9 ; p ++ ; } else { value += 1 ; } } else { value += 1 ; } } } return value ; }
returns the integer value of the given string of roman numerals .
