I'm making a roman numeral program where I enter any roman numeral (i.e XI) and receive an output of 11. I'm having trouble setting letters to integers :s:
Printable View
I'm making a roman numeral program where I enter any roman numeral (i.e XI) and receive an output of 11. I'm having trouble setting letters to integers :s:
Can you give an example?Quote:
having trouble setting letters to integers
By letters do you mean Strings? See the Integer class. It has a method to convert a String to an integer.
Uhhh well I was going to have the user input a value through Scanner and set it as
String word = reader.nextLine();
and then set X to be 10, I to be 1, etc, and then calculate a value. I'm a bit confused as to which function does that.
Java does not have a method for Roman Numerals. You will have to write one.Quote:
I'm a bit confused as to which function does that.
I don't know what classes you are allowed to use with this assignment. The Map class would be useful.
Or you might have to use a chain of if/else if statements to get the numeric value for a letter.