/** * * @Title: test_men_women_kids * @Description: 該方法的主要做用: * 男人+女人+小孩=30 * 一共花50先令 * 男人:3 女人:2 小孩:1 * @param 設定文件 * @return 返回類型:void * @throws */ @Test public void test_men_women_kids(){ int men = 0; int women = 0; int kids = 0; for (men = 0; men <=10; men++) { women = 20-2*men; kids = 30-men-women; if(3*men+2*women+kids==50){ System.out.println("男人有:"+men+",女人有:"+women+",小孩有:"+kids); } } }