void searchForPopulationChange()
{
String goAgain;
int input;
int searchCount = 0;
boolean found = false;
while(found == false){
System.out.println ("Enter the Number for Population Change to be found: ");
input = scan.nextInt();
for (searchCount = 0; searchCount < populationChange.length; searchCount++)
{
if (populationChange[searchCount] == input)
{
found = true;
System.out.print(""+countyNames[searchCount]+" County / City with a population of "+populationChange[searchCount]+" individuals\n");
}
}
}
}
}
hello! I am working on a method that will take an users input, lets say (5000) and search a data file with those corresponding numbers. and return the corresponding number, and county that it corresponds with.
However, I am able to get this code to run to return the correct value, but i am unable to get it to run when i enter an "incorrect" value.
Any pointers? Thank you!
foundand producing your error message if that was false? (Also, of course, you shouldbreakwhen the answer is found, to short-circuit the inner loop, or incorporatefoundin yourfortest.)