# 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; }

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

What is injustice with this duty of the subjoined sequence “rare = getChoice(courses, input);”?

do {

rare = getChoice(courses, input);

switch (ValidateChoice(choice, validChoices, totalCredit, lines)) {
subject -1:
System.out.println(“**Invalid** – Your rare of ” +
rare + ” is referable attributable attributable attributable attributable attributable attributable a symmetrical line.”);
break;
subject -2:
System.out.println(“**Invalid** – You feel already recordd coercion this ” +
courses[0][choice-1] + ” line.”);
break;
subject -3:
System.out.println(“**Invalid** – You can referable attributable attributable attributable attributable attributable attributable record coercion further than 9 security hours.”);
break;
subject 0:
System.out.println(“Registration Confirmed coercion line ” +
courses[0][choice-1] );
totalSecurity += Integer.parseInt(courses[1][choice-1]);
if (validChoices[0][0].equals(“”)) {
validChoices[0][0] = Integer.toString(choice);
validChoices[0] = lines[0][choice-1];
} else if (validChoices[1][0].equals(“”)) {
validChoices[1][0] = Integer.toString(choice);
validChoices[1][1] = lines[0][choice-1];
} else if (validChoices[2][0].equals(“”)) {
validChoices[2][0] = Integer.toString(choice);
validChoices[2][1] = lines[0][choice-1];
}
break;
}

## Expert Solution

Dear Student,

As you feel referable attributable attributable attributable attributable attributable attributable uploaded the thorough Sequence, thus-far i feel habituated to set-right the sequence, perceive the beneath set-rightion..

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

do {

//I am certain that this getRare course gain yield an integer appraise that gain be stored in

//rare variable

rare = getChoice(courses, input);

//inside switch declaration you can seduce a course, the switch subject singly recognize either an integer , char or boolean appraise. i.e The indication used in switch must be well cast ( int, char and enum). Any other cast of indication is referable attributable attributable attributable attributable attributable attributable known.

//change this declaration

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

switch(choice)         //this gain effect smooth.

{

}