void searchForPopulationChange()
{
int input;
int searchCount = 0;
System.out.println ("Enter the Number for Population Change to be found: ");
input = scan.nextInt();
boolean found = false;
for (searchCount = 0; searchCount < populationChange.length; searchCount++)
{
if (populationChange[searchCount] == input)
{
found = true;
break;
}
}
if (found)
{
System.out.print(""+countyNames[searchCount]+" County / City with a population of "+populationChange[searchCount]+" individuals\n");
}
else
{
System.out.print("WRONG INPUT");
}
}
}
你好,以上是我目前的程序。我在让它提取所有相应变量时遇到问题。IE:我输入“200”,数组中有 (2) 个单元具有相应的 (200) 值,但是,这只会打印出其中的 1 个。
任何人有任何快速指针?