These are the instructions for my program:
The first line on this file will hold a number indicating how many lines will follow. Every line after that will have a word and an integer on it. Fill up two arrays, one for the word and one for the integer. Once the arrays are filled, go to each element of the String array and print out that String the number of times the parallel number array says for it to print.
However, when I try to print out the answer, an error occurs, saying there's no line to pick up when reading from the file I'm supposed to.
Scanner input = new Scanner(new File("parallel.txt"));
int numLine = input.nextInt();
int [] array = new int[numLine];
String [] Stringarray = new String[numLine];
for (int i = 0; i< numLine; i++)
{
Stringarray[i] = input.next();
array[i] = input.nextInt();
input.nextLine();
}
for (int i = 0; i<Stringarray.length; i++)
{
for (int a = 0; a<array[a]; a++)
out.print(Stringarray[i] + " ");
out.println();
}
}
}