Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java n(); countRecords(); } 您可以将if更改为while并将剩余的代码从else public void createStudentRecord(Scanner in) { inputStudentID = null; i_Java_Loops - Fatal编程技术网

Java n(); countRecords(); } 您可以将if更改为while并将剩余的代码从else public void createStudentRecord(Scanner in) { inputStudentID = null; i

Java n(); countRecords(); } 您可以将if更改为while并将剩余的代码从else public void createStudentRecord(Scanner in) { inputStudentID = null; i,java,loops,Java,Loops,n(); countRecords(); } 您可以将if更改为while并将剩余的代码从else public void createStudentRecord(Scanner in) { inputStudentID = null; inputMark = 0; System.out.println("Enter Student ID: "); in.nextLine(); inputStudentID = in.nextLine(); if

n(); countRecords(); }
您可以将
if
更改为
while
并将剩余的代码从
else
public void createStudentRecord(Scanner in)
{
    inputStudentID = null;
    inputMark = 0;

    System.out.println("Enter Student ID: ");
    in.nextLine();
    inputStudentID = in.nextLine();
    if (!(inputStudentID.length()==6))
    {
        System.out.println("Enter a student ID that is 6 characters");
    }
    else
    {
        System.out.println("Enter Module Mark: ");
        inputMark = in.nextInt();
        if (inputMark <0 || inputMark >100)
        {
            System.out.println("PLease enter a module mark between 0-100");
        }
        else
        {
            addStudent(inputStudentID, inputMark);
            System.out.println();
            System.out.println("New student record has been " + 
                        "successfully created");
            System.out.println();
            countRecords();
        }
    }
}
public void createStudentRecord(Scanner in) {
    String inputStudentID = null;
    int inputMark = 0;

    while (true) {
        System.out.println("Enter Student ID: ");
        inputStudentID = in.nextLine();
        if (!(inputStudentID.length() == 6)) {
            System.out.println("Enter a student ID that is 6 characters");
        } else {
            break;
        }
    }

    while (true) {
        System.out.println("Enter Module Mark: ");
        inputMark = Integer.parseInt(in.nextLine());
        if (inputMark < 0 || inputMark > 100) {
            System.out.println("PLease enter a module mark between 0-100");
        } else {
            break;
        }
    }

    addStudent(inputStudentID, inputMark);
    System.out.println("\nNew student record has been successfully created.\n");
    countRecords();
}
public static void createStudentRecord(Scanner in)
{
    inputStudentID = null;
    inputMark = 0;

    System.out.println("Enter Student ID: ");
    in.nextLine();
    inputStudentID = in.nextLine();

    while (!(inputStudentID.length()==6))
    {
        System.out.println("Enter a student ID that is 6 characters");
    }

    System.out.println("Enter Module Mark: ");
    inputMark = in.nextInt();
    while (inputMark <0 || inputMark >100)
    {
        System.out.println("PLease enter a module mark between 0-100");
    }
    addStudent(inputStudentID, inputMark);
    System.out.println();
    System.out.println("New student record has been " + 
                "successfully created");
    System.out.println();
    countRecords();

}
public static void createStudentRecord(Scanner in)
{
    int timeout1 = 3, timeout2 = 3;

    inputStudentID = null;
    inputMark = 0;

    System.out.println("Enter Student ID: ");
    in.nextLine();
    inputStudentID = in.nextLine();

    while (!(inputStudentID.length()==6))
    {
        System.out.println("Enter a student ID that is 6 characters");
        --timeout1;
        if( timeout1 == 0 ) {
            System.out.println("say something here");
            return;
        }
    }

    System.out.println("Enter Module Mark: ");
    inputMark = in.nextInt();
    while (inputMark <0 || inputMark >100)
    {
        System.out.println("PLease enter a module mark between 0-100");
        --timeout2;
        if( timeout2 == 0 ) {
            System.out.println("say something here");
            return;
        }
    }
    addStudent(inputStudentID, inputMark);
    System.out.println();
    System.out.println("New student record has been " + 
                "successfully created");
    System.out.println();
    countRecords();

}