I'm making a program that reads from a file 3 numbers, doubles or integers, per line except the first one. The first line is the the number of lines after. The 3 numbers in each line are variables a, b, and c in the quadratic formula. Then the program is supposed to return the difference between the + and - part of the formula. Here is an example of what the file may contain.
3
1 2 4
1.5 3.12 4.31
0.09 5 2
My problem is the when using scanner to turn the tokens in the file into doubles so that they can be inputted to the quadratic formula, I am getting the following error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "1"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1250)
at java.lang.Double.parseDouble(Double.java:540)
at gorf.main(gorf.java:23)
here is part of my code:
int lines = Integer.parseInt(sc.nextLine());
double a;
double b;
double c;
String line = "";
Scanner abc = new Scanner(line);
for(int count = 0; count < lines; count++)
{
line = sc.nextLine();
abc = new Scanner(line);
a = Double.parseDouble(abc.next());
b = Double.parseDouble(abc.next());
c = Double.parseDouble(abc.next());
}