I'm trying to learn Java but I'm stuck at an exercise: I have to write a "decrypt()" method, that converts a String like b.aab and returns to double value 1.001.
I'm also given a 2 dimensional array of characters and the number they represent.
private static String conversionTable[][] = {
{"a", "0"},
{"b", "1"},
{"c", "2"},
{"d", "3"},
{"e", "4"},
{"f", "5"},
{"g", "6"},
{"h", "7"},
{"i", "8"},
{"j", "9"},
};
I know there is technique to convert a char ch into a digit with its ascii value, something like ch -'a' + 1, but I'm not sure how to apply this here. So my question is: How can I convert a String of letters to String of corresponding digits? From there I would use parseDouble(); to return a double of the String. Thank you in before.