MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / GetNum

Method GetNum

Java/roman-to-integer.java:2–26  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

1public class RomanToInteger{
2 public static int GetNum(int num) {//gets the number assoicate with a roman character
3 if (num == 'I' || num == 'i') {
4 return 1;
5 }
6 if (num == 'V' || num == 'v') {
7 return 5;
8 }
9 if (num == 'X' || num == 'x') {
10 return 10;
11 }
12 if (num == 'L' || num == 'l') {
13 return 50;
14 }
15 if (num == 'C' || num == 'c') {
16 return 100;
17 }
18 if (num == 'D' || num == 'd') {
19 return 500;
20 }
21 if (num == 'M' || num == 'm') {
22 return 1000;
23 }
24
25 return -1;
26 }
27
28 public static int romanToNumber(String roman){//Converts a roman numerial into a number
29 int results = 0;

Callers 1

romanToNumberMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected