+ 1
Java
Return the index of the first Roman Numeral in s or -1 if s contains no Roman Numerals
7 Answers
+ 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
+ 1
Is this a challenge, or you need help with a code?
+ 1
I need a help. Thanks!
+ 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?
+ 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?
+ 1
could you help me to fix this code?
https://code.sololearn.com/crY91k4Bgx7e/#java
+ 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