so this is my first real java program i have to write. I'm also fairly new to java..
The program must run with 2 command-line arguments, which are suppose to be x and y coordinates and then determines in which municipality and county the coordinates are. For this I'm suppose to use a 'winding number'.
BUT before I can start with those parts of the program, I first need to create and fill different array's , right?
The .txt file contains the following: (All places and coords are in the Netherlands btw) ID number county municipality. for example:
0 Groningen Haren
1 Groningen Leek
etc etc for the first 518 lines. The next 61650 lines or so are coordinates looking like this:
0 6.665039 53.181004
0 6.666431 53.180642
Where the first integer number ( here 0) corresponds with the municipality
To get back to the question. The textfile can not be altered, I have to use redirection(?) like in the cmd: java 'programname' < filename.txt. and it should read the entire file, create 1 array with only id numbers which are all integers. An array with the county and an array with municipality, right? But HOW do I create 3 different arrays ( oke 2, 1 integer array and 2 string arrays) when the data is on the same line..
I'm suppose to use StdIn.readInt, StdIn.readString and StdIn.readLine but I just cannot make it work.
Thanks in advance for any help.
This is what I have so far, It gives error because ( I think it's because of this) it expects to read an integer but there is also strings on that same line..
public class test{
public static void main(String[] args){
int n = 519;
Integer[] a = new Integer[n];
for(int i = 0; i < n; i++){
a[i] = StdIn.readInt();
StdOut.println(a[i]);
}
}
}