data input error
I am having a strange error I never had before. My program gives me the NumberFormatException every time, the matter what I type in. It seems to be trying to parse the text in the println instead of the actual input, because when I told it to print out "5", instead of "Enter X coordinate of target", it worked. I have used a similar code in the past and it worked fine.
My code is this:
global variables:
static double xTarg= 0.0, yTarg= 0.0;
.
.
.
in main method:
BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("Enter X coordinate of target");
xTarg = Double.parseDouble(BR.readLine());
System.out.println("Enter Y coordinate of target");
yTarg = Double.parseDouble(BR.readLine());
}
catch (NumberFormatException e)
{
System.out.println("NumberFormatException has happened");
System.exit(0);
}
catch (IOException e)
{
System.out.println("bad input");
System.exit(0);
}

