I'm working on a program that reads a list of reviews and categorizes them based on their score and the words used in the reviews. The words scanned are based on a set of user inputs. All variables are initialized correctly. Here is the snippet:
System.out.print(GETWORD);
String currWord = scan.nextLine();
String holderWord = "";
currWord = currWord.toLowerCase();
double[] totReviews = new double[currWord.length()];
totReviewNum = 0.0;
int i = 0;
Scanner linescan = new Scanner(currWord);
while (linescan.hasNext()) {
holderWord = linescan.next();
totReviews[i] = review(holderWord, fileName); //outputs a double reviewScore based on the number of
// reviews in filename.txt that contain holderword
currCounter += numLines(holderWord + ".txt"); // outputs the number of reviews with holderword
i++;
}
for (int j = 0; j < i; j++) {
totReviewNum += totReviews[j];
}
totReviewNum /= i;
System.out.print("average score for those reviews is ");
System.out.printf("%.5f", totReviewNum);
However, I ran the debugger, and it said that currWord had no value, and linescan.hasNext() was false and skipped the while loop. How can I fix this?