View Single Post
Old Apr 13th, 2008, 12:55 AM   #9
manny85
Newbie
 
manny85's Avatar
 
Join Date: Apr 2008
Location: Ft Meade MD
Posts: 6
Rep Power: 0 manny85 is on a distinguished road
Re: Random "Letter" Generator

Actually I don't think I made it very clear what I meant now that I reread my last post. I agree that using Double.parseDouble will convert a string, which contains a number (1-10 in our case), to an actual double. However if a string is storing a set a characters, in this case A-J, then I don't think Double.parseDouble will take that character and convert it to its/a numerical form. If it does in fact do that what values do the A-J end up being (numerically)...0-9, 1-10, ASCII values? Hope that makes more sense and also explains to kewlgeye why I choose the switch statement because I don't think his current program will respond correctly if a user inputs a character.

Side note: Kewlgeye, are you trying to generate two separate random values meaning a random letter and a separate random number? In my code above I'm using the randomly generated number to retrieve the corresponding letter. So if a user inputs either the correct number or letter they win (1 or A, 2 or B, 3 or C, ... , 10 or J).
manny85 is offline   Reply With Quote