Alex: http://www.roseindia.net/java/beginners/entervaluesfromkeyboard.shtml Again, let me refer u 2 point b of my last post, e.g., I am not a java programmer. Google, however, was helpful in that regard. On 2/27/08, Alex Hall <mehgcap@xxxxxxx> wrote: > Exactly what does the parse() do? > > Have a great day, > Alex > > > ----- Original Message ----- > >From: "Jackie McBride" <abletec@xxxxxxxxx > >To: programmingblind@xxxxxxxxxxxxx > >Date sent: Wed, 27 Feb 2008 16:39:19 -0700 > >Subject: Re: create int out of several charArray elements > > >Alex: > >a) I see you're writing in java; > >b) I am not a java programmer; > >c) Regarding converting strings to integers, here is some code > that > >might prove helpful? > >Convert string to int > >public class ConvertStringToInt { > > public static void main(String[] args) { > > String aString = "78"; > > int aInt = Integer.parseInt(aString); > > >U should obviously chop off the letter portion of the string in > order > >to get the int value. I'm sure also that java must have a > char2int > >function so that u could convert it to its ascii equivalent if u > need > >to do that. > > >On 2/27/08, Jackie McBride <abletec@xxxxxxxxx> wrote: > >> What r u writing this in? > > >> On 2/27/08, Alex Hall <mehgcap@xxxxxxx> wrote: > >>> Hi all > >>> I am still working on Battleship for my class. I tell the user > >>> to type in coordinates as expected in battleship, that is, a1 or > >>> g4. I use a string to store that input, lowercase the string, > >>> then convert it to a char array and cast the first element (the > >>> letter) to an int, then subtract 97 since a actually means the > >>> first gameboard slot (0, ascii a is 97 and 97?97=0). I take the > >>> second element, the number, and cast to an int but subtract 49. > >>> The problem is that my professor wants nothing less than a 15x15 > >>> grid. If I continue converting the way I am, then a1 and a12 > >>> look the same to the program since array[1]=1 and that is all it > >>> looks for. How can I tell it that I want all elements after 0 > to > >>> be strung together to form an integer, but not added? Take b15. > >>> I don't want to turn elements 1 and 2 into 6 but rather keep > them > >>> as 1 and 5 but string them together as 15. Maybe there is a way > >>> to convert a string to an int? Thanks for any help. > > >>> Have a great day, > >>> Alex > >>> __________ > >>> View the list's information and change your settings at > >>> //www.freelists.org/list/programmingblind > > > > > >> -- > >> Jackie McBride > >> Please join my fight against breast cancer > >> > <http://teamacs.acsevents.org/site/TR?px=1790196&pg=personal&fr_i > d=3489 > >> & Check out my homepage at: > >> www.abletec.serverheaven.net > > > > >-- > >Jackie McBride > >Please join my fight against breast cancer > ><http://teamacs.acsevents.org/site/TR?px=1790196&pg=personal&fr_i > d=3489 > >& Check out my homepage at: > >www.abletec.serverheaven.net > >__________ > >View the list's information and change your settings at > >//www.freelists.org/list/programmingblind > > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > -- Jackie McBride Please join my fight against breast cancer <http://teamacs.acsevents.org/site/TR?px=1790196&pg=personal&fr_id=3489> & Check out my homepage at: www.abletec.serverheaven.net __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind