如何返回java中的特定while循环

如何返回java中的特定while循环,java,arrays,loops,for-loop,switch-statement,Java,Arrays,Loops,For Loop,Switch Statement,有人能帮我找出问题所在吗?无论我在课程/学生/年级菜单的最后选择了什么选项,课程总是回到年级循环 对不起,我还是个新手,如果你有时间请帮我修改代码 我们学校每门课都要求我这样做,所以时间太长了 import java.util.*; 公开课考试{ 公共静态void main(字符串[]args){ 扫描仪输入=新扫描仪(System.in); 字符crs='C'; char yrr='Y'; char Std='S'; char inv='Y'; 国际年、部门、学生; ArrayListyear

有人能帮我找出问题所在吗?无论我在课程/学生/年级菜单的最后选择了什么选项,课程总是回到年级循环

对不起,我还是个新手,如果你有时间请帮我修改代码

我们学校每门课都要求我这样做,所以时间太长了

import java.util.*;
公开课考试{
公共静态void main(字符串[]args){
扫描仪输入=新扫描仪(System.in);
字符crs='C';
char yrr='Y';
char Std='S';
char inv='Y';
国际年、部门、学生;
ArrayListyearlvl=新的ArrayList();
年份L.添加(“第一年”);
第二年添加(“第二年”);
第1年增补(“第3年”);
第1年增补(“第4年”);
第1年增补(“第5年”);
ArrayListSections=新的ArrayList();
字符串[]字母表={
“A”,
“B”,
“C”,
“D”,
“E”,
“F”,
“G”,
“H”,
“我”,
“J”,
“K”,
“L”,
“M”,
“N”,
“O”,
“P”,
“Q”,
“R”,
“S”,
“T”,
“U”,
“五”,
“W”,
“X”,
“Y”,
“Z”
};
ArrayListSectionsName=new ArrayList();
ArrayListStudents=新建ArrayList();
ArrayListStudentsName=new ArrayList();
而((crs=='C'| | crs=='C')){
System.out.println(“=================================================================================================================================================================================================================================================================================================”;
System.out.println(“\n Mantasan ng Lungsod ng Marikina\n”);
System.out.println(“请选择课程”\n);
System.out.println(“专业课程\初级教育学士(BEEd”);
System.out.println(“\n输入您选择的字母:”);
char course=input.next().charAt(0);
转换(课程){
案例“A”:
案例“a”:
System.out.println(“\n欢迎来到基础教育学士学院!\n您想主修特殊教育吗?(Y表示是)”;
char se=input.next().charAt(0);
if((se='y'| | se=='y')){
System.out.println(“\n您选择了特殊教育专业!”);
而((yrr='Y'| | yrr=='Y')){
System.out.println(“\n选择要创建新节的年份级别:\n1.第一年\n2.第二年\n3.第三年\n4.第四年\n5.第五年\n输入您选择的编号:”);
yrlvl=input.nextInt();
而((Std='S'| | Std='S')){
System.out.println(“\n要为“+yearlvl.get(yrlvl-1)+”创建多少节?\n如果没有,请输入0”);
sections=input.nextInt();
对于(int i=1;i StudNum=newarraylist(q);
input.nextLine();
对于(int w=0;wimport java.util.*;

public class Test
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        char crs = 'C';
        char yrr = 'Y';
        char Std = 'S';
        char inv = 'Y';
        int yrlvl, sections, students;
        ArrayList<String> yearlvl = new ArrayList<String>();
        yearlvl.add("First Year");
        yearlvl.add("Second Year");
        yearlvl.add("Third Year");
        yearlvl.add("Fourth Year");
        yearlvl.add("Fifth Year");
        ArrayList<String> Sections = new ArrayList<String>();
        String[] alphabet = {
                "A",
                "B",
                "C",
                "D",
                "E",
                "F",
                "G",
                "H",
                "I",
                "J",
                "K",
                "L",
                "M",
                "N",
                "O",
                "P",
                "Q",
                "R",
                "S",
                "T",
                "U",
                "V",
                "W",
                "X",
                "Y",
                "Z"
        };
        ArrayList<String> SectionsName = new ArrayList<String>();
        ArrayList<String> Students = new ArrayList<String>();
        ArrayList<String> StudentsName = new ArrayList<String>();
        courseLoop : while ((crs == 'C' || crs == 'c'))
        {
            System.out.println("========================================================================================");
            System.out.println("\nPamantasan ng Lungsod ng Marikina\n");
            System.out.println("Please choose a Course\n");
            System.out.println("Professional Programs \nA.Bachelor in Elementary Education (BEEd");
            System.out.println("Enter your letter of your choice:");
            char course = input.next().charAt(0);

            switch (course)
            {
                case 'A':
                case 'a':
                    System.out.println("\nWelcome to College of Bachelor in Elementary Education!\nDo you want to get major in Special education? (Y for yes)");
                    char se = input.next().charAt(0);
                    if ((se == 'y' || se == 'Y'))
                    {
                        System.out.println("\nYou've chosen to get the major in Special Education!");
                        yearLoop : while ((yrr == 'Y' || yrr == 'y'))
                        {
                            System.out.println("\nChoose the year level you want to create new section:\n1.First Year\n2.Second Year\n3.Third Year\n4.Fourth Year\n5.Fifth Year\nEnter the number of your choice:");
                            yrlvl = input.nextInt();
                            sectionsLoop : while ((Std == 'S' || Std == 's'))
                            {
                                System.out.println("How many Section you want to create for " + yearlvl.get(yrlvl - 1) + "? \nEnter 0 if none");
                                sections = input.nextInt();
                                for (int i = 1; i <= sections; i++)
                                {
                                    String xx;
                                    System.out.print("Section #" + i + "\nEnter The Section Name No Spaces: ");
                                    xx = input.next();
                                    SectionsName.add(xx);
                                } //for for (sections-i)
                                System.out.println("\nThe following are section/s for " + yearlvl.get(yrlvl - 1) + ".");
                                for (int i = 0; i < SectionsName.size(); i++)
                                {
                                    System.out.println(alphabet[i] + "." + SectionsName.get(i));
                                } //for section names display
                                System.out.println("\nDo you want to add students or view students? ADD or DISPLAY:\nA. Add\n\nEnter your choice");
                                char choice = input.next().charAt(0);
                                if (choice == 'A' || choice == 'a')
                                {
                                    System.out.println("The list of sections");
                                    for (int i = 0; i < SectionsName.size(); i++)
                                    {
                                        System.out.println((i + 1) + "." + SectionsName.get(i));
                                    }
                                    System.out.println("Enter the number of section in which you want to insert students");
                                    int i = input.nextInt();
                                    System.out.println("You've chosen " + SectionsName.get(i - 1));
                                    System.out.println("\nEnter the number of students you want in " + SectionsName.get(i - 1) + "\nEnter 0 if none");
                                    int q = input.nextInt();
                                    ArrayList<String> StudNum = new ArrayList<String>(q);
                                    input.nextLine();
                                    for (int w = 0; w < q; w++)
                                    {
                                        System.out.println("Student #" + (w + 1) + " Name: ");
                                        String xxx = input.nextLine();
                                        StudNum.add(xxx);
                                    } //StudNum
                                    inv = 'Y';
                                    while (inv == 'Y')
                                    {
                                        System.out.println("\nReturn to A.Section Menu | B.Year Level Menu | C.Course Menu | D.Exit\nEnter the letter of your choice:");
                                        crs = 'x';
                                        yrr = 'x';
                                        Std = 'x';
                                        char chs = input.next().charAt(0);
                                        switch (chs)
                                        {
                                            case 'a':
                                            case 'A':
                                                crs = 'x';
                                                yrr = 'x';
                                                Std = 's';
                                                Std = 'S';
                                                inv = 'x';
                                                continue sectionsLoop;
                                            case 'b':
                                            case 'B':
                                                crs = 'x';
                                                yrr = 'y';
                                                yrr = 'Y';
                                                Std = 's';
                                                inv = 'x';
                                                continue yearLoop;
                                            case 'c':
                                            case 'C':
                                                crs = 'c';
                                                crs = 'C';
                                                yrr = 'y';
                                                Std = 's';
                                                inv = 'x';
                                                continue courseLoop;
                                            case 'd':
                                            case 'D':
                                                System.exit(0);
                                            default:
                                                System.out.println("Invalid Choice");
                                                crs = 'c';
                                                yrr = 'y';
                                                Std = 'S';
                                                break;
                                        } //for switch(Chs)
                                    } //while(inv)
                                } //for while (Std)
                            } //for while (yrr)
                        } //if (choiceA)
                    } //for if (se)
            } // For while (crs)
        } // For Switch (course)

    }
}