By using this site, you agree to our Privacy Policy and our Terms of Use. Close

I know enough Java to know I hate the language

Anyways, you don't need your giant IF section if you simplify. If you can convert your Word into an array of characters, then you can do hex manipulation and convert back into a string. (look up a ascii table if you really need to figure out how this works)

You then need to loop through this for each index in the phone number.

//char is the current index in the phone number
if(char >= 0x61) //adjust for lowercase letters
{
char -= 0x20;
}
char -= 0x40;
if(char >= 0x13) //key 7 has 4 characters, so we have to shift everything down 1
{
char -= 1;
}
char = (char-1)/3 + 2; //make sure this is integer math or things will get messed up
if(char == 10) //z is on the 9th key, and the only 1 that would show up on 10.
{
char -= 1;
}
number += char.ToString();

this could be simplified down a tiny bit more but isn't really needed. Also note that I wrote this as a C# based code and I wouldn't know the exact syntax for Java.

anyways, your IF statments are broken now anyways, so might as well replace them. Your current setup will cause you to check 1 number only. You really need a for loop to index through all the characters in the phone number.




If you drop a PS3 right on top of a Wii, it would definitely defeat it. Not so sure about the Xbox360. - mancandy
In the past we played games. In the future we watch games. - Forest-Spirit
11/03/09 Desposit: Mod Bribery (RolStoppable)  vg$ 500.00
06/03/09 Purchase: Moderator Privilege  vg$ -50,000.00

Nordlead Jr. Photo/Video Gallery!!! (Video Added 4/19/10)