|
-
April 25th, 2008, 05:12 PM
#1
need help with validation..
i wont to includ a validation for these...but i dont no how !!?
Code:
if (x==1)
{
inp =JOptionpane.showInputDialoge("Enter Number of miles')
int y= Integer.parseInt(inp);
double miles=c.KmToMiles(y);
JOptionpane.showmessageDialog(null,"Miles="+miles);
}
if (x==2)
{
inp =JOptionpane.showInputDialoge("Enter Number of km ")
int y= Integer.parseInt(inp);
double km=c.MilesToKm(y);
JOptionpane.showmessageDialog(null,"km="+km);
}
how can i do it ..!!!!!!???
Last edited by nadykool; April 25th, 2008 at 05:14 PM.
Reason: speling
-
April 26th, 2008, 03:42 AM
#2
Re: need help with validation..
Code you posted does not compile. Send something that does compile, makes it well easier to see where you actually have issues. Meanwhile, check this tutorial, seems to be right down your alley.
http://www.leepoint.net/notes-java/G...ptionpane.html
-
April 27th, 2008, 02:08 AM
#3
Re: need help with validation..
Otherwise if you are trying to make sure you have a valid number, take a look at Integer.parseInt(String) and make note that it can throw NumberFormatException. To handle that, try taking a look at handling exceptions. I am not sure what you were asking however.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|