I want to take a multiple coordinate points, say (35,-21) (55,12)... from standard input and put them into respective arrays.
Let's call them x[] and y[].
x[] would contain {35, 55, ...} and y[] would contain {-21, 12, ...} and so forth.
However, I can't seem to find a way to get around the parenthesis and commas.
In c I was using the following:
for(i = 0; i < SIZE; i++) {
scanf("%*c%d%*c%d%*c%*c",&x[i],&y[i]);
}
However in Java I can not seem to find a way to get around the non-numeric characters.
I currently have the following in Java, as I am stuck.
double[] x = new double[SIZE];
double[] y = new double[SIZE];
Scanner sc = new Scanner(System.in);
for(int i=0; i < SIZE; i++) {
x[i] = sc.nextDouble();
}
So the question: How would I ignore characters when reading in doubles from scanner?
A quick edit:
My goal is to keep the strict syntax (12,-55) on user input, and being able to enter multiple rows of coordinate points such as:
(1,1) (2,2) (3,3) ...