我有以下简单的主菜单,其中没有调用任何方法,当在每个菜单中选择退出选项时,我不知道如何使子菜单退出主菜单? 我是初学者,这个项目非常重要,好像我失败了,尽管已经支付了费用,但我将无法参加考试:(
菜单代码(到目前为止)如下:
*//菜单将包含 6 个列表,分别是:书籍、成员、员工、贷款、统计信息、退出。
//这些从 1 到 4 的列表将打开一个子菜单,其中包括:插入、搜索、删除、编辑、全部列出、退出。
//清单 5 将包括:前 5 本书、前 5 名成员、当月员工、过期列表、退出。
import java.util.*;
import java.io.*;
public class Menu
{
public static void main(String args[]) throws IOException
{
Scanner sc = new Scanner(System.in);
int option;
do
{
System.out.println("Main Menu:");
System.out.println("1. Books");
System.out.println("2. Members");
System.out.println("3. Employees");
System.out.println("4. Loans");
System.out.println("5. Statistics");
System.out.println("6. Exit");
System.out.println("Enter your option [1,2,3,4,5,6]:");
option = sc.nextInt();
switch (option) {
case 1: System.out.println("Books Sub-Menu:");
System.out.println("1. Insert");
System.out.println("2. Search");
System.out.println("3. Delete");
System.out.println("4. Edit");
System.out.println("5. List All");
System.out.println("6. Exit");
System.out.println("Enter your option [1,2,3,4,5,6]:");
option = sc.nextInt();
switch (option){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
option = sc.nextInt();
break;
}
break;
case 2: System.out.println("Members Sub-Menu:");
System.out.println("1. Insert");
System.out.println("2. Search");
System.out.println("3. Delete");
System.out.println("4. Edit");
System.out.println("5. List All");
System.out.println("6. Exit");
System.out.println("Enter your option [1,2,3,4,5,6]:");
option = sc.nextInt();
switch (option){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
option = sc.nextInt();
break;
}
break;
case 3: System.out.println("Employees Sub-Menu:");
System.out.println("1. Insert");
System.out.println("2. Search");
System.out.println("3. Delete");
System.out.println("4. Edit");
System.out.println("5. List All");
System.out.println("6. Exit");
System.out.println("Enter your option [1,2,3,4,5,6]:");
option = sc.nextInt();
switch (option){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
option = sc.nextInt();
break;
}
break;
case 4: System.out.println("Loans Sub-Menu:");
System.out.println("1. Insert");
System.out.println("2. Search");
System.out.println("3. Delete");
System.out.println("4. Edit");
System.out.println("5. List All");
System.out.println("6. Exit");
System.out.println("Enter your option [1,2,3,4,5,6]:");
option = sc.nextInt();
switch (option){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
option = sc.nextInt();
break;
}
break;
case 5: System.out.println("Statistics Sub-Menu:");
System.out.println("1. Top 5 Books");
System.out.println("2. Top 5 Members");
System.out.println("3. Emplyee of the Month");
System.out.println("4. List Overdue");
System.out.println("5. Exit");
System.out.println("Enter your option [1,2,3,4,5]:");
option = sc.nextInt();
switch (option){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
option = sc.nextInt();
break;
}
break;
case 6: System.out.println("You selected to Exit");
System.exit(0);
break;
}
} while (option!=6);
}
}*