用户输入if语句跳过

时间:2014-02-23 22:16:38

标签: java if-statement input

所以我想要完成的是让用户能够订购一个项目,到目前为止只是土豆,然后使用“是”或“否”输入确认订单。然而,正在发生的是辅助输入if语句被跳过并且其余代码运行。谁能告诉为什么这些if语句没有正确实现?

if(next.contains("potatoes")); {

        // Add in the quantity function later;
        System.out.println("\nAre you sure you want to add potatoes?");
    }
            if(next.contains("yes")); {
                System.out.println("\nYour basket:" + itemOne +" " +  potatoCost);
            }
            if(next.contains("no")); {
                System.out.println("You have not added " +itemOne + " to your cart.");
            }
            }

    while ( next.equalsIgnoreCase("exit") == false );

        System.out.println("You have decided to stop shopping!");
        System.exit(0);  
        }

}

0 个答案:

没有答案