Skip to content
Advertisement

Converting String number words to just String number:Java

I’m a beginner coder trying to work on converter for words which should work that way:Input= “zero;six;eight;two” Output = “0682”. But in my case the output I get is “0282”. Are there any solutions to that? Or like maybe I should program differently?. I found that LinkedLists or HashMap could work, if so could you show how?

JavaScript

Advertisement

Answer

You should be splitting your semicolon-separated input on ;, and then iterating each term in a loop:

JavaScript

For an input of zero;six;eight;two this was the output from the above script:

JavaScript
Advertisement