Results 1 to 5 of 5
Thread: newbie question
- 02-01-2012, 09:45 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
newbie question
Hi, I have just started with java, I'm playing with application which will ask for few numbers and do some calculations on them.
I have few methods already, and the one, that will handle the calculations is going to be asking user for couple of numbers.
I have managed to display input box and apply error message in case integer is not a result of the input...
Now I want to ask for another few numbers with same error handling...
Newbie way would be to just to copy whole chunk of the code few more times..
My question is:
Can I do it in a different way?
- 02-01-2012, 10:14 PM #2
Senior Member
- Join Date
- Aug 2011
- Posts
- 249
- Rep Power
- 2
Re: newbie question
Just use the OR operator to ask few boolean questions in one if statement.
Ask first if it's an Integer because if not, you will get a type mismatch error incase the input is not an Integer.
- 02-01-2012, 10:14 PM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: newbie question
Are you familiar with loops?
The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
- 02-01-2012, 10:21 PM #4
Senior Member
- Join Date
- Aug 2011
- Posts
- 249
- Rep Power
- 2
Re: newbie question
If he wants to ask few question on one input box he can do that by one if statement.
Or I didn't understand his question
- 02-01-2012, 10:41 PM #5
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Similar Threads
-
Newbie Question - Switch
By R0bert0 in forum New To JavaReplies: 1Last Post: 07-16-2011, 04:19 AM -
Probably a newbie question.... :P
By gblax123 in forum New To JavaReplies: 9Last Post: 02-23-2011, 10:21 PM -
Newbie question
By MrNiceGuy in forum New To JavaReplies: 8Last Post: 11-12-2010, 05:29 AM -
newbie question
By ronguilmet in forum New To JavaReplies: 2Last Post: 11-16-2009, 02:37 AM -
Newbie question; Vectors
By Kern in forum New To JavaReplies: 7Last Post: 08-03-2008, 06:59 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks