I am a student, I'm trying to practice hashmaps. I can input roman numerals inside loops and if statements to convert into accurate decimals. i want to enter MDCLXVI.
public static void main(String[] args) {
String inputstr;
Integer outputstr ;
System.out.println("Enter Roman Numneral(s): ");
Scanner sc = new Scanner(System.in);
inputstr = sc.nextLine().toUpperCase();
HashMap<String, Integer> numeral = new HashMap<String, Integer>();
numeral.put("IV", 4);
numeral.put("IX", 9);
numeral.put("XL", 40);
numeral.put("CD", 400);
numeral.put("CM", 900);
numeral.put("C", 100);
numeral.put("M", 1000);
numeral.put("I", 1);
numeral.put("V", 5);
numeral.put("X", 10);
numeral.put("L", 50);
numeral.put("D", 500);
outputstr = numeral.get(inputstr);
System.out.println(inputstr + " = " + outputstr);
}
My question is: how can I enter more than one key to get desired decimal?