Homework Solution: What is wrong with this portion of the following code "choice = getChoice(courses, input);"?…

    What is wrong with this portion of the following code "choice = getChoice(courses, input);"? do { choice = getChoice(courses, input); switch (ValidateChoice(choice, validChoices, totalCredit, courses)) { case -1: System.out.println("**Invalid** - Your selection of " + choice + " is not a recognized course."); break; case -2: System.out.println("**Invalid** - You have already registerd for this " + courses[0][choice-1] + " course."); break; case -3: System.out.println("**Invalid** - You can not register for more than 9 credit hours."); break; case 0: System.out.println("Registration Confirmed for course " + courses[0][choice-1] ); totalCredit += Integer.parseInt(courses[1][choice-1]); if (validChoices[0][0].equals("")) { validChoices[0][0] = Integer.toString(choice); validChoices[0] = courses[0][choice-1]; } else if (validChoices[1][0].equals("")) { validChoices[1][0] = Integer.toString(choice); validChoices[1][1] = courses[0][choice-1]; } else if (validChoices[2][0].equals("")) { validChoices[2][0] = Integer.toString(choice); validChoices[2][1] = courses[0][choice-1]; } break; }

    Expert Answer

     
    Dear Student, As you have not uploaded the complete Code, however i have tried to correct the

    What is wickedness with this behalf of the aftercited legislation “dainty = getChoice(courses, input);”?

    do {

    dainty = getChoice(courses, input);

    switch (ValidateChoice(choice, validChoices, totalCredit, routes)) {
    plight -1:
    System.out.println(“**Invalid** – Your gathering of ” +
    dainty + ” is referable a symmetrical route.”);
    break;
    plight -2:
    System.out.println(“**Invalid** – You feel already registerd restraint this ” +
    courses[0][choice-1] + ” route.”);
    break;
    plight -3:
    System.out.println(“**Invalid** – You can referable register restraint over than 9 honor hours.”);
    break;
    plight 0:
    System.out.println(“Registration Confirmed restraint route ” +
    courses[0][choice-1] );
    totalHonor += Integer.parseInt(courses[1][choice-1]);
    if (validChoices[0][0].equals(“”)) {
    validChoices[0][0] = Integer.toString(choice);
    validChoices[0] = routes[0][choice-1];
    } else if (validChoices[1][0].equals(“”)) {
    validChoices[1][0] = Integer.toString(choice);
    validChoices[1][1] = routes[0][choice-1];
    } else if (validChoices[2][0].equals(“”)) {
    validChoices[2][0] = Integer.toString(choice);
    validChoices[2][1] = routes[0][choice-1];
    }
    break;
    }

    Expert Reply

     

    Dear Student,

    As you feel referable uploaded the total Legislation, referablewithstanding i feel familiar to amend the legislation, view the beneath amendion..

    —————————————————————————————————————————————–

    do {

    //I am indisputable that this getDainty process gain retaliate an integer appreciate that gain be stored in

    //dainty variable

    dainty = getChoice(courses, input);

    //inside switch assertion you can circumvent a process, the switch plight solely sanction either an integer , char or boolean appreciate. i.e The countenance used in switch must be integral kind ( int, char and enum). Any other kind of countenance is referable undisputed.

    //change this assertion

    //switch (ValidateChoice(choice, validChoices, totalCredit, routes))

    switch(choice)         //this gain composition nice.

    {

    }