Setting a value that has parameters
I'm looking for a way to set the value index.totalNumCitations to the
value I set in that while loop. I set the value to 1 initially so the for
loop would execute at least once. I tried obtaining the value before the
for loop and that also wasn't working. If someone could point me in the
right direction I would be very appreciative.
for (int i = 0; i < index.totalNumCitations; i++) {
while (inputInteger > 50 || inputInteger < 0) {
inputInteger = Integer.parseInt(sc.nextLine());
index.Index(inputInteger);
}
This is the method used in the while loop
public void Index(int totalNumCit) {
if (totalNumCit <= 50 && totalNumCit > 0) {
this.totalNumCitations = totalNumCit;
citationIndex = new Citation[totalNumCit];
} else {
System.out.println("Error: Please enter a number between 0 and 50.");
}
}
No comments:
Post a Comment