+ 1

Java

Return the index of the first Roman Numeral in s or -1 if s contains no Roman Numerals

5th Mar 2018, 2:45 AM
Tuyen Pham
Tuyen Pham - avatar
7 odpowiedzi
+ 2
So I decided that, for a char to be a roman numeral it has to be capitalized, the rest is simple https://code.sololearn.com/c0HxzWIr8gp9/?ref=app
5th Mar 2018, 3:21 AM
voidneo
+ 1
Is this a challenge, or you need help with a code?
5th Mar 2018, 2:51 AM
voidneo
+ 1
I need a help. Thanks!
5th Mar 2018, 2:52 AM
Tuyen Pham
Tuyen Pham - avatar
+ 1
Okay, so you've got this code, you ask for an input? and then return the index of the first capitalized I, X, L or M, is that right?
5th Mar 2018, 2:55 AM
voidneo
+ 1
I know but i dont know how to return the FIRST of roman numerals in a string? How to know it is the first?
5th Mar 2018, 3:02 AM
Tuyen Pham
Tuyen Pham - avatar
+ 1
could you help me to fix this code? https://code.sololearn.com/crY91k4Bgx7e/#java
5th Mar 2018, 3:38 AM
Tuyen Pham
Tuyen Pham - avatar
+ 1
I fixed it as much as I could, take a look, it works, but not as desired. My recommendation is to convert the char in the isRomanNumeral to a string, strings have a built in method to compare themselves to others strings, in this case, it is useful Try this: String str = "" + c; // c is the method parameter if( str.equals("I") ) return true; https://code.sololearn.com/c8piElA1PR2O/?ref=app
5th Mar 2018, 3:57 AM
voidneo