當前位置:菜譜大全網 - 菜譜 - Java,下面代碼如何按0返回上級菜單,我剛學Java是菜鳥,幫忙修改壹下,只用循環。

Java,下面代碼如何按0返回上級菜單,我剛學Java是菜鳥,幫忙修改壹下,只用循環。

公共類Main {

公共靜態void main(String[] args) {

布爾mj;

做{

系統。out . println(" \ t \ t \ t歡迎使用我們自己的購物管理系統");

System.out

。println(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");

System.out.println("1。客戶信息管理”);

System.out.println("2。購買結算”);

System.out.println("3。真實反饋”);

System.out.println("4。備註和pin”);

System.out

。println(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *);

System.out.println("請選擇並輸入壹個數字:");

int chief//系統菜單號

掃描儀輸入=新掃描儀(system . in);

chief = input . nextint();

mj =假;

if (chief == 1) {

System.out.println("走自己的路購物管理系統>客戶信息管理");

System.out

。println(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ");

系統。out.println ("\ t \ t 1。顯示所有客戶信息”);

System.out.println("\t\t\t2。添加客戶信息”);

System.out.println("\t\t\t3。修改客戶信息”);

System.out.println("\t\t\t4。查詢客戶信息”);

System.out

。println(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *);

System.out.println("輸入數字或按0返回上壹級菜單:");

int子菜單;//子菜單編號

subMenu = input . nextint();

System.out.println(子菜單);

if(子菜單== 0){

mj =真;

繼續;

}

布爾a;

做{

a =假;

開關(子菜單){

案例1:

System.out.println("按執行顯示所有客戶信息");

打破;

案例二:

System.out.println("執行添加客戶信息");

打破;

案例三:

System.out.println("執行客戶信息修改");

打破;

案例4:

System.out.println("查詢客戶信息");

打破;

默認值:

System.out.println("您的輸入有誤!\ n請選擇、輸入壹個數字或按0返回上壹級:");

a =真;

}

} while(a);

} else if (chief == 2) {

System.out.println("執行購物結算");

} else if (chief == 3) {

System.out.println("實現真反饋");

} else if (chief == 4) {

System.out.println("執行註銷");

}否則{

System.out.println("輸入錯誤,請重新輸入!");

mj =真;

}

} while(mj);

}

}