s3a
September 12th, 2009, 10:05 PM
The following (java code) allows the user to input a double but it forces an output of an integer:
int variable = (int)kb.nextDouble();
That is what I want but I also want the user to be able to input letters and still be denied with a printed error message (which I've already set up as was the case before with another similar problem) but I just don't know what I have to change so that the user can input any characters (although the program will not print anything other than integers. How do I make it do what it currently does but also take in other character inputs?
Any help would be greatly appreciated!
Thanks in advance!
int variable = (int)kb.nextDouble();
That is what I want but I also want the user to be able to input letters and still be denied with a printed error message (which I've already set up as was the case before with another similar problem) but I just don't know what I have to change so that the user can input any characters (although the program will not print anything other than integers. How do I make it do what it currently does but also take in other character inputs?
Any help would be greatly appreciated!
Thanks in advance!