Given statements: //Switch to score switch (score) { //Case case (score > 90): //Assign the grade grade = 'A'; //Break the statement break; //Case case (score > 80): //Assign the grade grade = 'b'; //Break the statement break; //Case case (score > 70): //Assign the grade grade = 'C'; //Break the statement break; //Case case (score > 60): //Assign the grade grade = 'D'; //Break the statement break; //Default Case default: //Assign the grade grade = 'F'; } Error in the given statement: Error #1: The case statements itself cannot contain an expression. The “case” must be carried out with an integer or a character. The given code cannot be modified as the “switch” statement because it contains expressions. It can only be converted into “if-else-if” statement that is given below...
Given statements: //Switch to score switch (score) { //Case case (score > 90): //Assign the grade grade = 'A'; //Break the statement break; //Case case (score > 80): //Assign the grade grade = 'b'; //Break the statement break; //Case case (score > 70): //Assign the grade grade = 'C'; //Break the statement break; //Case case (score > 60): //Assign the grade grade = 'D'; //Break the statement break; //Default Case default: //Assign the grade grade = 'F'; } Error in the given statement: Error #1: The case statements itself cannot contain an expression. The “case” must be carried out with an integer or a character. The given code cannot be modified as the “switch” statement because it contains expressions. It can only be converted into “if-else-if” statement that is given below...
Solution Summary: The given code cannot be modified as the "switch" statement because it contains expressions.
The case statements itself cannot contain an expression. The “case” must be carried out with an integer or a character. The given code cannot be modified as the “switch” statement because it contains expressions. It can only be converted into “if-else-if” statement that is given below...