java - 尝试获得“是//否”提示来工作。不会接受回应

标签 java arrays

void searchForPopulationChange()
  {
     String goAgain;
     String response;
     int input;
     int searchCount = 0;
     boolean found = false;
     boolean search = false; 


     while(search == 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)
           {
              System.out.print(""+countyNames[searchCount]+" County / City with a population of "+populationChange[searchCount]+" individuals\n");
              found = true;
           } 

        }

        if (found == false) {
           System.out.println("No records found!");
        }


        System.out.println("\n\n-------------------------------------------------------------------------");
        System.out.println("\n\tDo you want to enter data for another Course? Type Yes or No: "); 
        response = scan.nextLine(); //the response is already recognized - thus ends or restarts the program      

        if (response.equalsIgnoreCase("yes"));
        {
           search = false;
        }

        if (response.equalsIgnoreCase("no"));
        {
           search = true;
        }      



     }


  }

} 你好! 这是我到目前为止的程序 基本上, 当 while 循环结束时, 我需要它提示用户是否希望再次执行该程序。 是还是不是? 我收到打印提示 但是,扫描功能不起作用。 有什么建议吗?

最佳答案

删除分号

if (response.equalsIgnoreCase("yes"));

if (response.equalsIgnoreCase("no"));

关于java - 尝试获得“是//否”提示来工作。不会接受回应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17737273/

相关文章:

javascript - 用另一个数组过滤数组

ruby - 计数 Ruby 1.8.6 中数组中值的实例

java - g.Init();找不到标志

java - 如何缩短井字游戏中的 if 语句以检查行等?

C程序给出奇怪的输出

从 C 中现有的一维数组创建二维数组?

java - 什么是 WEKA 中的集群评估?

java - Java 中的 GridLayout 帮助

java - PrintWriter 输出到 body 标记内的 jsp 页面

java - 带有 Subversion 的 Jenkins 最好导出?