14+ Java Roman to Decimal Converters

This post contains a total of 14+ Hand-Picked Java Roman to Decimal converter examples with source code. All the Roman to Decimal converters are made using Java Programming Language.

You can use the source code of these programs for educational use with credits to the original owner.

Related Posts

Click a Code to Copy it.

1. By Ram chandra Giri

Made by Ram chandra Giri. Java program to convert roman number to decimal. ( Source )

import java.util.*;

public class RomanToDec
/*Friend this is a Roman to Decimal Converter. I have problem with NullPointerException
  in my code please help.
 
*/
{
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in); 
        //System.out.println("You have entered text to Reverse \r\n");  
        String s=sc.nextLine().toUpperCase();
        
        try {
            Boolean check = isValid(s);
        if( check ){
            System.out.println("String is not a valid Roman numeral.");
        } else {
            String rti = String.valueOf(romanToInteger(s));
            System.out.println("Decimal no. is: " + rti);
        }
        } catch (NullPointerException e) {
            System.out.print("Caught NullPointerException, Please enter a valid Roman numeral\r\n");
            System.out.print("Please help me remove this NullPointer, I am not being able to do it.");
        }
        
        System.out.println("\r\nFriends Please Give Your Valuable Suggestion.");    
    }
    public static int romanToInteger(String s) {
    Map<Character, Integer> T = new HashMap<Character, Integer>() {
      {
        put('I', 1);
        put('V', 5);
        put('X', 10);
        put('L', 50);
        put('C', 100);
        put('D', 500);
        put('M', 1000);
      }
    };

    int sum = T.get(s.charAt(s.length() - 1));
    for (int i = s.length() - 2; i >= 0; --i) {
      if (T.get(s.charAt(i)) < T.get(s.charAt(i + 1))) {
        sum -= T.get(s.charAt(i));
      } else {
        sum += T.get(s.charAt(i));
      }
    }
    return sum;
   }
   public static boolean isValid(String word) {
        String input = "^\bM{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})\b$";
        //String input = "^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$";Another test
        java.util.regex.Pattern p = java.util.regex.Pattern.compile(input);
        java.util.regex.Matcher m = p.matcher(word);
        return m.matches();
    }
}

2. By Evgeniy Druzhkov

Made by Evgeniy Druzhkov. ( Source )


public class Programm
 {

    public static void main(String[] args) {
        System.out.println(decimal2Roman(34));
        System.out.println(roman2Decimal("XXXIV"));
    }

    public static String decimal2Roman(int dec) {
        String[] romanCharacters = {"C", "XC", "L", "X", "IX", "V", "I"};
        int[] romanValues = {100, 90, 50, 10, 9, 5, 1};
        String result = "";

        for (int i = 0; i < romanValues.length; i++) {
            int numberInPlace = dec / romanValues[i];
            if (numberInPlace == 0) {
                continue;
            }
            result = numberInPlace == 4 && i > 0
                    ? result + romanCharacters[i] + romanCharacters[i - 1]
                    : result + new String(new char[numberInPlace]).replace("\0", romanCharacters[i]);
            dec = dec % romanValues[i];
        }
        return result;
    }

    public static int roman2Decimal(String roman) {
        char[] arrayRoman = roman.toCharArray();
        int lengthArray = arrayRoman.length;
        int[] arrayDecimal = new int[lengthArray];
        int maxValue = 0;
        int indexerMaxValue = 0;
        int result = 0;
        for (int i = 0; i < lengthArray; i++) {
            int tmp;
            switch (arrayRoman[i]) {
                case 'I':
                    tmp = 1;
                    break;
                case 'V':
                    tmp = 5;
                    break;
                case 'X':
                    tmp = 10;
                    break;
                case 'L':
                    tmp = 50;
                    break;
                case 'C':
                    tmp = 100;
                    break;
                default:
                    return 0;
            }
            arrayDecimal[i] = tmp;
            if (tmp > maxValue) {
                maxValue = tmp;
                indexerMaxValue = i;
            }
        }
        for (int j = 0; j < lengthArray; j++) {
            if (j < indexerMaxValue) {
                result = result - arrayDecimal[j];
            } else {
                result = (j == lengthArray - 1 || arrayDecimal[j] >= arrayDecimal[j + 1])
                        ? result + arrayDecimal[j]
                        : result - arrayDecimal[j];
            }
        }
        return result;
    }
}

3. By Mahesh Chhilwal

Made by Mahesh Chhilwal. ( Source )

//Program: Roman Number to Decimal

import java.io.*;
public class RomanToDecimal
{
    public static void romanToDecimal(java.lang.String romanNumber)
    {
        int decimal = 0;
        int lastNumber = 0;
        String romanNumeral = romanNumber.toUpperCase();
         
        for (int x = romanNumeral.length() - 1; x >= 0 ; x--)
        {
            char convertToDecimal = romanNumeral.charAt(x);

            switch (convertToDecimal)
            {
                case 'M':
                    decimal = processDecimal(1000, lastNumber, decimal);
                    lastNumber = 1000;
                    break;

                case 'D':
                    decimal = processDecimal(500, lastNumber, decimal);
                    lastNumber = 500;
                    break;

                case 'C':
                    decimal = processDecimal(100, lastNumber, decimal);
                    lastNumber = 100;
                    break;

                case 'L':
                    decimal = processDecimal(50, lastNumber, decimal);
                    lastNumber = 50;
                    break;

                case 'X':
                    decimal = processDecimal(10, lastNumber, decimal);
                    lastNumber = 10;
                    break;

                case 'V':
                    decimal = processDecimal(5, lastNumber, decimal);
                    lastNumber = 5;
                    break;

                case 'I':
                    decimal = processDecimal(1, lastNumber, decimal);
                    lastNumber = 1;
                    break;
            }
        }
        System.out.println("Decimal number : "+decimal);
    }

    public static int processDecimal(int decimal, int lastNumber, int lastDecimal)
    {
        if (lastNumber > decimal)
        {
            return lastDecimal - decimal;
        }
        else
        {
            return lastDecimal + decimal;
        }
    }

    public static void main(java.lang.String args[])
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter Roman Number : ");

        String roman = null;
        try
        {
            roman = br.readLine();    
        }
        catch(IOException e)
        {
            System.out.println(e.getMessage());
        }
        
        romanToDecimal(roman);
    }
}

4. By MUNJETI TARUN

Made by MUNJETI TARUN/ Simple program to convert roman into decimal. ( Source )

import java.util.*;
import java.util.Scanner ;
public class Program
{

    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    System.out.print("enter Roman Literal : ");
    
    String s = sc.next();
    
    System.out.println(s);
    Program p1 = new Program();
    
    System.out.println("Integer Version of Roman Numeral : "+p1.RtD(s));
    
    }
    
    int RtD (String str)
    {
        int res=0;
        for(int i=0;i<str.length();i++)
        {
          int v1 = value(str.charAt(i));
          
          if(i+1<str.length())
          {
              
        int  v2=value(str.charAt(i+1));
          
          if(v1>=v2)
              res = res + v1;
          else
             {res=res+v2-v1;
                i++;
                }
          }
          else{
              res+=v1;
              i++;
              }
              }
              return res;
    }
    public int value(char r)
    {
        if(r=='I' | r=='i')
            return 1 ;
            
        if(r=='V' | r=='v')
            return  5  ;
            
        if(r=='X' | r=='x')
            return  10;
            
        if(r=='L' | r=='l')
            return   50 ;
            
            
        if(r=='C' | r=='c')
            return  100  ;
            
            
         if(r=='D' | r=='d')
            return   500;
            
            
        if(r=='M' | r=='m')
            return   1000;
            
            
        else
            return -1 ;     
    }
}

5. By Pavan Rajesh

Made by Pavan Rajesh. ( Source )


import java.util.*;
public class RomanToNumber 
{
    
    public static void main(String args[])
    {
        
        Roman r=new Roman();
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a Roman NUmber");
        String str =sc.nextLine();
        int res = 0;
        for (int i = 0; i < str.length(); i++) 
        {
            int s1 = r.romanToInteger(str.charAt(i));
            if (i + 1 < str.length()) 
            {
                int s2 =r.romanToInteger(str.charAt(i + 1));
                if (s1 >= s2) 
                {
                    res = res + s1;
                }
                else
                {
                    res = res + s2 - s1;
                    i++;
                }
            }
            else 
            {
                res = res + s1;
            }
        }
        
        System.out.println("Integer form of Roman Numeral"+" is "+res);

    }
}
public class Roman
{
    public int romanToInteger(char r)
    {
        if (r=='I')
            return 1;
        else if (r=='V')
            return 5;
        else if(r=='X')
            return 10;
        if (r=='L')
            return 50;
        if (r=='C')
            return 100;
        if (r=='D')
            return 500;
        if (r=='M')
            return 1000;
        return -1;
    }
}

6. By Nutopzhe

Made by Nutopzhe. ( Source )

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Input a roman number to be converted to decimal: ");
        String romanString = bufferedReader.readLine();
        System.out.println("Conversion result equals = " + romanToInteger(romanString));
    }

    public static int romanToInteger(String s) {
        int lastNumber = 0;
        int decimal = 0;
        String romanNumeral = s.toUpperCase();

        for (int i = romanNumeral.length() - 1; i >= 0; i--) {
            char convertToDecimal = romanNumeral.charAt(i);

            switch (convertToDecimal) {
                case 'I' -> {
                    decimal = processDecimal(1, lastNumber, decimal);
                    lastNumber = 1;
                }
                case 'V' -> {
                    decimal = processDecimal(5, lastNumber, decimal);
                    lastNumber = 5;
                }
                case 'X' -> {
                    decimal = processDecimal(10, lastNumber, decimal);
                    lastNumber = 10;
                }
                case 'L' -> {
                    decimal = processDecimal(50, lastNumber, decimal);
                    lastNumber = 50;
                }
                case 'C' -> {
                    decimal = processDecimal(100, lastNumber, decimal);
                    lastNumber = 100;
                }
                case 'D' -> {
                    decimal = processDecimal(500, lastNumber, decimal);
                    lastNumber = 500;
                }
                case 'M' -> {
                    decimal = processDecimal(1000, lastNumber, decimal);
                    lastNumber = 1000;
                }
                default -> {
                    System.out.println("This is not roman number. Please try again");
                    System.exit(0);
                }
            }
        }
        return decimal;
    }

    public static int processDecimal(int decimal, int lastNumber, int lastDecimal) {
        if (lastNumber > decimal) {
            return lastDecimal - decimal;
        } else {
            return lastDecimal + decimal;
        }
    }
}

7. By Gersimucaal

Made by Gersimucaal. Program for Converting roman numerals to decimal. ( Source )


public class RomanToInt {
	
    public String intToRoman(int num){
	    // Can be improve by turning arrays into hash map
    	String romans[] = {"I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD",  "D", "CM", "M"};
    	int value[] = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
    	
    	int index = romans.length - 1;
    	String answer = "";
        	while(num>0){
        		while(value[index]<=num){
            // "" + "M"
            // 1994 = 1994- 1000
            // 6 = 6- 1 = 5
        			answer += romans[index];
        			num -= value[index];
        }
        		index--;
    }
        return answer;
 }
}

8. By shanedonaldson

Made by shanedonaldson. A simple java converter used to convert roman numerals to their decimal equivalent. ( Source )

import java.util.Scanner;

public class EnterRomanNumeral {

	public static void main(String[] args) {
		
		//create new RomanToDecimal object
		RomanToDecimal converter = new RomanToDecimal();
		
		//prompt user for decimal
        System.out.println("Enter a roman numeral to be converted: ");
        
        //call method from RomanToDecimal class
        converter.GetRoman();
	}

}

public class RomanToDecimal {
	
	//method to process the characters from the romanToDecimal method
	public int ProcessRoman(int TotalDecimal, int LastRomanLetter, int LastDecimal) {
        if (LastRomanLetter > TotalDecimal) {
            return LastDecimal - TotalDecimal;
        } else {
            return LastDecimal + TotalDecimal;
        }
    }

    public void romanToDecimal(String roman) {
    	//declare variables
        int decimal = 0;
        int lastNumber = 0;
        //create variable to convert to the string to all uppercase
        String romanNumeral = roman.toUpperCase();
        //start a loop to parse the string
        for (int x = romanNumeral.length() - 1; x >= 0; x--) {
        	//declare variable to define character position
            char convertToDecimal = romanNumeral.charAt(x);
            //switch case for the value of each character
            switch (convertToDecimal) {
                case 'M':
                    decimal = ProcessRoman(1000, lastNumber, decimal);
                    lastNumber = 1000;
                    break;

                case 'D':
                    decimal = ProcessRoman(500, lastNumber, decimal);
                    lastNumber = 500;
                    break;

                case 'C':
                    decimal = ProcessRoman(100, lastNumber, decimal);
                    lastNumber = 100;
                    break;

                case 'L':
                    decimal = ProcessRoman(50, lastNumber, decimal);
                    lastNumber = 50;
                    break;

                case 'X':
                    decimal = ProcessRoman(10, lastNumber, decimal);
                    lastNumber = 10;
                    break;

                case 'V':
                    decimal = ProcessRoman(5, lastNumber, decimal);
                    lastNumber = 5;
                    break;

                case 'I':
                    decimal = ProcessRoman(1, lastNumber, decimal);
                    lastNumber = 1;
                    break;
            }
        }
        //print the roman numeral's value
        System.out.println(romanNumeral + " is equal to " + decimal);
    }
    //method to be called from main
    public void GetRoman() {
    	//create scanner
        Scanner getRoman = new Scanner(System.in);
        String Roman = getRoman.next();
        
        //call method to convert roman numeral
        romanToDecimal(Roman);
        
        //close scanner
        getRoman.close();
    }
}

9. By Luis Ospina

Made by Luis Ospina. ( Source )

package main;

public class RomanoToDecimal {
	public int romanoDecimal(String roman){
		int suma = 0;
		for(int i = 0; i<roman.length();i++){
			if(i > 0 && charToRoman(roman.charAt(i-1)) < charToRoman(roman.charAt(i))){
				suma-=2*charToRoman(roman.charAt(i-1));
			}
			suma+=charToRoman(roman.charAt(i));				
				
		}
		return suma;
	}
	
	public int charToRoman(char a){
		if(a == 'I'){
			return 1;
		}else if(a == 'V'){
			return 5;
		}else if(a == 'X'){
			return 10;
		}else if(a == 'L'){
			return 50;
		}else if(a == 'C'){
			return 100;
		}else if(a == 'D'){
			return 500;
		}else if(a == 'M'){
			return 1000;
		}
		
		return -1;
	}
	
}

10. By 23morrisc

Made by 23morrisc. ( Source )

/**
 * converts roman numerals to decimals
 * @version 10/3/2021
 * @author 23morrisc
 */

public class RomanToDecimal {

    /**
     * calculates value in decimal
     * @param roman
     */

    public static int romanToDecimal(String roman) {
        int decimal = 0;
        for(int i = 0; i < roman.length(); i++) {
            //System.out.println(roman.length());
            //System.out.println("DEBUG: " + roman.substring(i, i+1).toUpperCase());

            //finds the value of the RN by looking at each character and assessing its value in decimal
            if (roman.substring(i, i + 1).toUpperCase().equals("I")) {
                decimal += 1;
            } else if (roman.substring(i, i + 1).toUpperCase().equals("V")) {
                decimal += 5;
            } else if (roman.substring(i, i + 1).toUpperCase().equals("X")) {
                decimal += 10;
            } else if (roman.substring(i, i + 1).toUpperCase().equals("L")) {
                decimal += 50;
            } else if (roman.substring(i, i + 1).toUpperCase().equals("C")) {
                decimal += 100;
            } else if (roman.substring(i, i + 1).toUpperCase().equals("D")) {
                decimal += 500;
            } else if (roman.substring(i, i + 1).toUpperCase().equals("M")) {
                decimal += 1000;
            } else {
                return -1;
            }
        }

            //Finds the reductions within the RN and subtracts the amount necessary to compensate for original error
            if (roman.toUpperCase().indexOf("IV") != -1)
                decimal -=2;
            if (roman.toUpperCase().indexOf("IX") != -1)
                decimal -=2;
            if (roman.toUpperCase().indexOf("XL") != -1)
                decimal -=20;
            if (roman.toUpperCase().indexOf("XC") != -1)
                decimal -=20;
            if (roman.toUpperCase().indexOf("CD") != -1)
                decimal -=200;
            if (roman.toUpperCase().indexOf("CM") != -1)
                decimal -=200;

        return decimal;
    }

    /**
     * runs the romanToDecimal method for all args
     * @param args
     */

    public static void main(String[] args) {
        for(String temp : args) {
            int val = romanToDecimal(temp);
            //DEBUGGING: System.out.println(val);

            //Checks for validity in the returned decimal value and prints the result
            if(val == -1) {
                System.out.println("Input: " + temp + " => output: invalid");
            }
            else {
                System.out.println("Input: " + temp + " => output: " + romanToDecimal(temp));
            }
        }
    }
}

11. By Patrick Bucher

Made by Patrick Bucher. ( Source )

package ch.paedubucher.romanNumerals;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class RomanNumerals {

    private static final Map<String, Integer> romanToDecimal = new LinkedHashMap<>();
    private static final Map<Integer, String> decimalToRoman = new LinkedHashMap<>();

    static {
        romanToDecimal.put("I", 1);
        romanToDecimal.put("V", 5);
        romanToDecimal.put("X", 10);
        romanToDecimal.put("L", 50);
        romanToDecimal.put("C", 100);
        romanToDecimal.put("D", 500);
        romanToDecimal.put("M", 1000);

        decimalToRoman.put(1, "I");
        decimalToRoman.put(4, "IV");
        decimalToRoman.put(5, "V");
        decimalToRoman.put(9, "IX");
        decimalToRoman.put(10, "X");
        decimalToRoman.put(40, "XL");
        decimalToRoman.put(50, "L");
        decimalToRoman.put(90, "XC");
        decimalToRoman.put(100, "C");
        decimalToRoman.put(400, "CD");
        decimalToRoman.put(500, "D");
        decimalToRoman.put(900, "CM");
        decimalToRoman.put(1000, "M");
    }

    public static int toNumber(final String roman) {
        if (roman == null || roman.trim().equals("")) {
            return 0;
        }
        checkOnlyRomanCharacters(roman.toUpperCase());
        final List<String> tokens = tokenize(roman.toUpperCase());
        int result = 0;
        for (final String token : tokens) {
            result += evaluate(token);
        }
        return result;
    }

    private static void checkOnlyRomanCharacters(final String upperRoman) {
        upperRoman.chars().mapToObj(i -> (char) i).forEach(c -> {
            final String str = String.valueOf(c);
            if (!romanToDecimal.containsKey(str)) {
                throw new IllegalArgumentException("'" + str + "' is no roman numeral");
            }
        });
    }

    private static List<String> tokenize(final String upperRoman) {
        final List<String> tokens = new ArrayList<>();
        final char[] chars = new StringBuilder(upperRoman).reverse().toString().toCharArray();
        StringBuilder token = new StringBuilder();
        String last = String.valueOf(chars[0]);
        token.append(last);
        for (int i = 1; i < chars.length; i++) {
            final String current = String.valueOf(chars[i]);
            // MCMLXXXIV -> M|CM|L|XXX|IV
            if (romanToDecimal.get(current) > romanToDecimal.get(last)) {
                tokens.add(token.reverse().toString());
                token = new StringBuilder(current);
            } else {
                token.append(current);
            }
            last = current;
        }
        tokens.add(token.reverse().toString());
        return tokens;
    }

    private static Integer evaluate(final String token) {
        final List<String> items =
            token.chars().mapToObj(i -> String.valueOf((char) i)).collect(Collectors.toList());
        String last = items.get(0);
        Integer result = romanToDecimal.get(last);
        for (int i = 1; i < items.size(); i++) {
            final String current = items.get(i);
            final Integer currentValue = romanToDecimal.get(current);
            final Integer lastValue = romanToDecimal.get(last);
            if (currentValue > lastValue) {
                result = -result + currentValue;
            } else {
                result += currentValue;
            }
            last = current;
        }
        return result;
    }

    public static String toRoman(int number) {
        if (number < 0) {
            throw new IllegalArgumentException("negative numbers are not supported");
        }
        String result = "";
        while (number > 0) {
            final int delta = smallerNumeral(number);
            final String roman = decimalToRoman.get(delta);
            result += roman;
            number -= delta;
        }
        return result;
    }

    private static int smallerNumeral(int value) {
        return decimalToRoman.keySet().stream()
            .filter(x -> x <= value)
            .sorted() // ascending
            .reduce((first, second) -> second) // last item
            .orElseThrow(() -> new IllegalArgumentException("no numeral <= " + value));
    }

12. By Nikki

Made by Nikki. ( Source )


/**
 * 
 * @author Nikki Mcintyre
 * Will figure out a decimal value from roman numerals
 * I.E.
 * 'VII' returns 7
 * 'IV' returns 4
 */
import java.util.ArrayList;
import java.util.Scanner;
class Solution {
  //the roman numerals and thier decimal value
  private static final int I = 1;
  private static final int V = 5;
  private static final int X = 10;
  private static final int L = 50;
  private static final int C = 100;
  private static final int D = 500;
  private static final int M = 1000;
  public static void main(String[] args) {
    //get the input and send it to the method to solve
    System.out.println("Enter a **valid** roman numerial (there is no error checking yet)"); //TODO: add error checking
    Scanner kbd = new Scanner(System.in);
    int answer = romanToInt(kbd.next());
    kbd.close();
    System.out.println(answer);
  }

  /**
   * 
   * @param s inputted roman numeral
   * @return converted s in decimal 
   */
  public static int romanToInt(String s) {
    //container for the decimal solution
    int answer = 0;
    //ArrayList of the roman numerals that are given
    ArrayList<Character> chars = new ArrayList<Character>();
    //ArrayList of the decimal values of the roman numerals
    ArrayList<Integer> results = new ArrayList<Integer>();
    //add all the characters to the chars arraylist
    for (char c : s.toCharArray()) {
      chars.add(c);
    }
    //add the corresponding decimal values in the appropriate place in the results ArrayList
    for (int i = 0; i < chars.size(); i++){
      if(chars.get(i) == 'I'){
        results.add(I);
      }
      if(chars.get(i) == 'V'){
        results.add(V);
      }  
      if(chars.get(i) == 'X'){
        results.add(X);
      }  
      if(chars.get(i) == 'L'){
        results.add(L);
      }  
      if(chars.get(i) == 'C'){
        results.add(C);
      } 
      if(chars.get(i) == 'D'){
        results.add(D);
      } 
      if(chars.get(i) == 'M'){
        results.add(M);
      }    
    }

    //add the values from the results arraylist up to get a single decimal number
    for(int i = 0; i < results.size(); i++){
      /*
      HOWEVER this is why I can't just add them all up in the previous step. Roman numerials are a little tricky 'VI' = 6 but 'IV' = 4. 
      So I figure out if the current index is smaller than the next index like in the previous example I < V hten the value it actually refelects is V - I or 5 - 1 == 4
      this is true for all the numerals XI = 11 but IX = 9 or 10 - 1 etc 
      */
      if(i != results.size()-1){
        //if it is smaller then I add the results as I just mentioned, larger number - smaller one but then I got to add an extra iteration to I because otherwise I'd be repeating values
        if(results.get(i) < results.get(i+1)){
          answer += ((results.get(i+1)) - (results.get(i)));
          i++;
        }
        //add the value to answer
        else{
          answer += results.get(i);
        }
      }
      else{
        answer += results.get(i);
      }
    }
    //return the answe
    return answer;
  }
    
}

13. By Bcatarino

Made by Bcatarino. ( Source )

import java.util.ArrayList;
import java.util.List;

public class RomanConverter {

    public int convertRoman(String expression) {

        if (expression.length() == 0) {
            throw new IllegalArgumentException("At least one symbol is needed");
        }

        List<Integer> integers = convertExpression(expression);

        int total = 0;
        for (int i = 0; i < integers.size(); i++) {
            if (i == integers.size() - 1 || integers.get(i) >= integers.get(i+1)) {
                total += integers.get(i);
            } else {
                total += integers.get(i+1) - integers.get(i);
                i++;
            }
        }

        return total;
    }

    private List<Integer> convertExpression(String expression) {
        List<Integer> values = new ArrayList<>();
        for (char c : expression.toCharArray()) {
            values.add(mapNumber(c));
        }
        return values;
    }

    private Integer mapNumber(char symbol) {
        switch (symbol) {
            case 'I': return 1;
            case 'V': return 5;
            case 'X': return 10;
        }
        throw new IllegalArgumentException("Invalid symbol");
    }
}

14. By Ifelipemarin

Made by Ifelipemarin. ( Source )

package main;

/**
 * Created by felipe on 4/05/16.
 */
public class Conversion {

    public int convertRomanToDecimal(String roman) {
        //int i = 0;
        int v = 0;
        int[] nums = new int[roman.length()];
        int suma = 0;
        for (int j = 0; j < roman.length(); j++) {
            String romana = String.valueOf(roman.charAt(j));
            switch (romana.toUpperCase()) {
                case "I":
                    nums[j] = 1;
                    break;
                case "V":
                    nums[j] = 5;
                    break;
                case "X":
                    nums[j] = 10;
                    break;
                case "L":
                    nums[j] = 50;
                    break;
                case "C":
                    nums[j] = 100;
                    break;
                case "D":
                    nums[j] = 500;
                    break;
                case "M":
                    nums[j] = 1000;
                    break;
                default:
                    nums[j] = 0;
            }
        }

        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] < nums[i + 1]) {
                suma -= nums[i];
            } else {
                suma += nums[i];
            }
        }
        suma += nums[nums.length - 1];
        return suma;
    }
}

15. By jessemaa

Made by jessemaa. ( Source )

package com.company;

public class Main {

    public static void main(String[] args) {
        System.out.println(romanToDecimal("MMVI"));
        System.out.println(romanToDecimal("MCMXLIV"));
    }

    public static int value(char i) {
        if (i == 'I') { return 1; }
        if (i == 'V') { return 5; }
        if (i == 'X') { return 10; }
        if (i == 'L') { return 50; }
        if (i == 'C') { return 100; }
        if (i == 'D') { return 500; }
        if (i == 'M') { return 1000; }
        else { return -1; }
    }

    public static int romanToDecimal(String romanNumber) {
        int num = 0;

        for (int i = 0; i < romanNumber.length(); i++) {
            int value1 = value(romanNumber.charAt(i));

            if (i + 1 < romanNumber.length()) {
                int value2 = value(romanNumber.charAt(i + 1));
                if (value1 >= value2) {
                    num += value1;
                } else {
                    num += value2 - value1;
                    i++;
                }
            } else { num += value1; }
        }
        return num;
    }
}